// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso;

import fmod.fmod.FMODSoundEmitter;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import se.krka.kahlua.vm.KahluaTable;
import zombie.Lua.LuaEventManager;
import zombie.Lua.LuaManager;
import zombie.ai.ZombieGroupManager;
import zombie.ai.states.FakeDeadZombieState;
import zombie.audio.BaseSoundEmitter;
import zombie.audio.DummySoundEmitter;
import zombie.audio.ObjectAmbientEmitters;
import zombie.characters.HaloTextHelper;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.IsoSurvivor;
import zombie.characters.IsoZombie;
import zombie.characters.SurvivorDesc;
import zombie.characters.TriggerSetAnimationRecorderFile;
import zombie.characters.ZombieVocalsManager;
import zombie.characters.professions.ProfessionFactory;
import zombie.characters.traits.TraitFactory;
import zombie.core.Core;
import zombie.core.PerformanceSettings;
import zombie.core.Rand;
import zombie.core.SpriteRenderer;
import zombie.core.TilePropertyAliasMap;
import zombie.core.Translator;
import zombie.core.logger.ExceptionLogger;
import zombie.core.math.PZMath;
import zombie.core.physics.WorldSimulation;
import zombie.core.profiling.PerformanceProfileProbe;
import zombie.core.properties.PropertyContainer;
import zombie.core.skinnedmodel.DeadBodyAtlas;
import zombie.core.skinnedmodel.model.WorldItemAtlas;
import zombie.core.stash.StashSystem;
import zombie.core.textures.Texture;
import zombie.core.utils.OnceEvery;
import zombie.debug.DebugLog;
import zombie.debug.LineDrawer;
import zombie.erosion.ErosionGlobals;
import zombie.gameStates.GameLoadingState;
import zombie.globalObjects.GlobalObjectLookup;
import zombie.input.Mouse;
import zombie.inventory.ItemPickerJava;
import zombie.inventory.types.MapItem;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.SpriteDetails.IsoObjectType;
import zombie.iso.areas.IsoBuilding;
import zombie.iso.areas.SafeHouse;
import zombie.iso.areas.isoregion.IsoRegions;
import zombie.iso.objects.IsoDeadBody;
import zombie.iso.objects.IsoFireManager;
import zombie.iso.objects.ObjectRenderEffects;
import zombie.iso.objects.RainManager;
import zombie.iso.sprite.IsoDirectionFrame;
import zombie.iso.sprite.IsoSprite;
import zombie.iso.sprite.IsoSpriteGrid;
import zombie.iso.sprite.IsoSpriteManager;
import zombie.iso.sprite.SkyBox;
import zombie.iso.weather.ClimateManager;
import zombie.iso.weather.WorldFlares;
import zombie.iso.weather.fog.ImprovedFog;
import zombie.iso.weather.fx.WeatherFxMask;
import zombie.network.BodyDamageSync;
import zombie.network.ClientServerMap;
import zombie.network.GameClient;
import zombie.network.GameServer;
import zombie.network.NetChecksum;
import zombie.network.PassengerMap;
import zombie.network.ServerMap;
import zombie.network.ServerOptions;
import zombie.popman.ZombiePopulationManager;
import zombie.radio.ZomboidRadio;
import zombie.randomizedWorld.randomizedBuilding.RBBar;
import zombie.randomizedWorld.randomizedBuilding.RBBasic;
import zombie.randomizedWorld.randomizedBuilding.RBBurnt;
import zombie.randomizedWorld.randomizedBuilding.RBBurntCorpse;
import zombie.randomizedWorld.randomizedBuilding.RBBurntFireman;
import zombie.randomizedWorld.randomizedBuilding.RBCafe;
import zombie.randomizedWorld.randomizedBuilding.RBClinic;
import zombie.randomizedWorld.randomizedBuilding.RBHairSalon;
import zombie.randomizedWorld.randomizedBuilding.RBKateAndBaldspot;
import zombie.randomizedWorld.randomizedBuilding.RBLooted;
import zombie.randomizedWorld.randomizedBuilding.RBOffice;
import zombie.randomizedWorld.randomizedBuilding.RBOther;
import zombie.randomizedWorld.randomizedBuilding.RBPileOCrepe;
import zombie.randomizedWorld.randomizedBuilding.RBPizzaWhirled;
import zombie.randomizedWorld.randomizedBuilding.RBSafehouse;
import zombie.randomizedWorld.randomizedBuilding.RBSchool;
import zombie.randomizedWorld.randomizedBuilding.RBShopLooted;
import zombie.randomizedWorld.randomizedBuilding.RBSpiffo;
import zombie.randomizedWorld.randomizedBuilding.RBStripclub;
import zombie.randomizedWorld.randomizedBuilding.RandomizedBuildingBase;
import zombie.randomizedWorld.randomizedVehicleStory.RVSAmbulanceCrash;
import zombie.randomizedWorld.randomizedVehicleStory.RVSBanditRoad;
import zombie.randomizedWorld.randomizedVehicleStory.RVSBurntCar;
import zombie.randomizedWorld.randomizedVehicleStory.RVSCarCrash;
import zombie.randomizedWorld.randomizedVehicleStory.RVSCarCrashCorpse;
import zombie.randomizedWorld.randomizedVehicleStory.RVSChangingTire;
import zombie.randomizedWorld.randomizedVehicleStory.RVSConstructionSite;
import zombie.randomizedWorld.randomizedVehicleStory.RVSCrashHorde;
import zombie.randomizedWorld.randomizedVehicleStory.RVSFlippedCrash;
import zombie.randomizedWorld.randomizedVehicleStory.RVSPoliceBlockade;
import zombie.randomizedWorld.randomizedVehicleStory.RVSPoliceBlockadeShooting;
import zombie.randomizedWorld.randomizedVehicleStory.RVSTrailerCrash;
import zombie.randomizedWorld.randomizedVehicleStory.RVSUtilityVehicle;
import zombie.randomizedWorld.randomizedVehicleStory.RandomizedVehicleStoryBase;
import zombie.randomizedWorld.randomizedZoneStory.RZSBBQParty;
import zombie.randomizedWorld.randomizedZoneStory.RZSBaseball;
import zombie.randomizedWorld.randomizedZoneStory.RZSBeachParty;
import zombie.randomizedWorld.randomizedZoneStory.RZSBuryingCamp;
import zombie.randomizedWorld.randomizedZoneStory.RZSFishingTrip;
import zombie.randomizedWorld.randomizedZoneStory.RZSForestCamp;
import zombie.randomizedWorld.randomizedZoneStory.RZSForestCampEaten;
import zombie.randomizedWorld.randomizedZoneStory.RZSHunterCamp;
import zombie.randomizedWorld.randomizedZoneStory.RZSMusicFest;
import zombie.randomizedWorld.randomizedZoneStory.RZSMusicFestStage;
import zombie.randomizedWorld.randomizedZoneStory.RZSSexyTime;
import zombie.randomizedWorld.randomizedZoneStory.RZSTrapperCamp;
import zombie.randomizedWorld.randomizedZoneStory.RandomizedZoneStoryBase;
import zombie.savefile.ClientPlayerDB;
import zombie.savefile.PlayerDB;
import zombie.savefile.PlayerDBHelper;
import zombie.savefile.ServerPlayerDB;
import zombie.text.templating.TemplateText;
import zombie.ui.TutorialManager;
import zombie.util.AddCoopPlayer;
import zombie.util.SharedStrings;
import zombie.util.Type;
import zombie.vehicles.PolygonalMap2;
import zombie.vehicles.VehicleIDMap;
import zombie.vehicles.VehicleManager;
import zombie.vehicles.VehiclesDB2;
import zombie.world.WorldDictionary;
import zombie.world.WorldDictionaryException;
import zombie.world.moddata.GlobalModData;

public final class IsoWorld {
    private String weather = "sunny";
    public final IsoMetaGrid MetaGrid = new IsoMetaGrid();
    private final ArrayList<RandomizedBuildingBase> randomizedBuildingList = new ArrayList();
    private final ArrayList<RandomizedZoneStoryBase> randomizedZoneList = new ArrayList();
    private final ArrayList<RandomizedVehicleStoryBase> randomizedVehicleStoryList = new ArrayList();
    private final RandomizedBuildingBase RBBasic = new RBBasic();
    private final HashMap<String, ArrayList<Double>> spawnedZombieZone = new HashMap();
    private final HashMap<String, ArrayList<String>> allTiles = new HashMap();
    private final ArrayList<String> tileImages = new ArrayList();
    private float flashIsoCursorA = 1.0F;
    private boolean flashIsoCursorInc = false;
    public SkyBox sky = null;
    private static zombie.PredicatedFileWatcher m_setAnimationRecordingTriggerWatcher;
    private static boolean m_animationRecorderActive = false;
    private static boolean m_animationRecorderDiscard = false;
    private int timeSinceLastSurvivorInHorde = 4000;
    private int m_frameNo = 0;
    public final Helicopter helicopter = new Helicopter();
    private boolean bHydroPowerOn = false;
    public final ArrayList<IsoGameCharacter> Characters = new ArrayList();
    private final ArrayDeque<BaseSoundEmitter> freeEmitters = new ArrayDeque();
    private final ArrayList<BaseSoundEmitter> currentEmitters = new ArrayList();
    private final HashMap<BaseSoundEmitter, IsoObject> emitterOwners = new HashMap();
    public int x = 50;
    public int y = 50;
    public IsoCell CurrentCell;
    public static IsoWorld instance = new IsoWorld();
    public int TotalSurvivorsDead = 0;
    public int TotalSurvivorNights = 0;
    public int SurvivorSurvivalRecord = 0;
    public HashMap<Integer, SurvivorDesc> SurvivorDescriptors = new HashMap();
    public ArrayList<AddCoopPlayer> AddCoopPlayers = new ArrayList();
    private static final IsoWorld.CompScoreToPlayer compScoreToPlayer = new IsoWorld.CompScoreToPlayer();
    static IsoWorld.CompDistToPlayer compDistToPlayer = new IsoWorld.CompDistToPlayer();
    public static String mapPath = "media/";
    public static boolean mapUseJar = true;
    boolean bLoaded = false;
    public static final HashMap<String, ArrayList<String>> PropertyValueMap = new HashMap();
    private static int WorldX = 0;
    private static int WorldY = 0;
    private SurvivorDesc luaDesc;
    private ArrayList<String> luatraits;
    private int luaSpawnCellX = -1;
    private int luaSpawnCellY = -1;
    private int luaPosX = -1;
    private int luaPosY = -1;
    private int luaPosZ = -1;
    public static final int WorldVersion = 195;
    public static final int WorldVersion_Barricade = 87;
    public static final int WorldVersion_SandboxOptions = 88;
    public static final int WorldVersion_FliesSound = 121;
    public static final int WorldVersion_LootRespawn = 125;
    public static final int WorldVersion_OverlappingGenerators = 127;
    public static final int WorldVersion_ItemContainerIdenticalItems = 128;
    public static final int WorldVersion_VehicleSirenStartTime = 129;
    public static final int WorldVersion_CompostLastUpdated = 130;
    public static final int WorldVersion_DayLengthHours = 131;
    public static final int WorldVersion_LampOnPillar = 132;
    public static final int WorldVersion_AlarmClockRingSince = 134;
    public static final int WorldVersion_ClimateAdded = 135;
    public static final int WorldVersion_VehicleLightFocusing = 135;
    public static final int WorldVersion_GeneratorFuelFloat = 138;
    public static final int WorldVersion_InfectionTime = 142;
    public static final int WorldVersion_ClimateColors = 143;
    public static final int WorldVersion_BodyLocation = 144;
    public static final int WorldVersion_CharacterModelData = 145;
    public static final int WorldVersion_CharacterModelData2 = 146;
    public static final int WorldVersion_CharacterModelData3 = 147;
    public static final int WorldVersion_HumanVisualBlood = 148;
    public static final int WorldVersion_ItemContainerIdenticalItemsInt = 149;
    public static final int WorldVersion_PerkName = 152;
    public static final int WorldVersion_Thermos = 153;
    public static final int WorldVersion_AllPatches = 155;
    public static final int WorldVersion_ZombieRotStage = 156;
    public static final int WorldVersion_NewSandboxLootModifier = 157;
    public static final int WorldVersion_KateBobStorm = 158;
    public static final int WorldVersion_DeadBodyAngle = 159;
    public static final int WorldVersion_ChunkSpawnedRooms = 160;
    public static final int WorldVersion_DeathDragDown = 161;
    public static final int WorldVersion_CanUpgradePerk = 162;
    public static final int WorldVersion_ItemVisualFullType = 164;
    public static final int WorldVersion_VehicleBlood = 165;
    public static final int WorldVersion_DeadBodyZombieRotStage = 166;
    public static final int WorldVersion_Fitness = 167;
    public static final int WorldVersion_DeadBodyFakeDead = 168;
    public static final int WorldVersion_Fitness2 = 169;
    public static final int WorldVersion_NewFog = 170;
    public static final int WorldVersion_DeadBodyPersistentOutfitID = 171;
    public static final int WorldVersion_VehicleTowingID = 172;
    public static final int WorldVersion_VehicleJNITransform = 173;
    public static final int WorldVersion_VehicleTowAttachment = 174;
    public static final int WorldVersion_ContainerMaxCapacity = 175;
    public static final int WorldVersion_TimedActionInstantCheat = 176;
    public static final int WorldVersion_ClothingPatchSaveLoad = 178;
    public static final int WorldVersion_AttachedSlotType = 179;
    public static final int WorldVersion_NoiseMakerDuration = 180;
    public static final int WorldVersion_ChunkVehicles = 91;
    public static final int WorldVersion_PlayerVehicleSeat = 91;
    public static final int WorldVersion_MediaDisksAndTapes = 181;
    public static final int WorldVersion_AlreadyReadBooks1 = 182;
    public static final int WorldVersion_LampOnPillar2 = 183;
    public static final int WorldVersion_AlreadyReadBooks2 = 184;
    public static final int WorldVersion_PolygonZone = 185;
    public static final int WorldVersion_PolylineZone = 186;
    public static final int WorldVersion_NaturalHairBeardColor = 187;
    public static final int WorldVersion_CruiseSpeedSaving = 188;
    public static final int WorldVersion_KnownMediaLines = 189;
    public static final int WorldVersion_DeadBodyAtlas = 190;
    public static final int WorldVersion_Scarecrow = 191;
    public static final int WorldVersion_DeadBodyID = 192;
    public static final int WorldVersion_IgnoreRemoveSandbox = 193;
    public static final int WorldVersion_MapMetaBounds = 194;
    public static final int WorldVersion_PreviouslyEntered = 195;
    public static int SavedWorldVersion = -1;
    private boolean bDrawWorld = true;
    private final ArrayList<IsoZombie> zombieWithModel = new ArrayList();
    private final ArrayList<IsoZombie> zombieWithoutModel = new ArrayList();
    public static boolean NoZombies = false;
    public static int TotalWorldVersion = -1;
    public static int saveoffsetx;
    public static int saveoffsety;
    public boolean bDoChunkMapUpdate = true;
    private long emitterUpdateMS;
    public boolean emitterUpdate;
    private int updateSafehousePlayers = 200;

    public IsoMetaGrid getMetaGrid() {
        return this.MetaGrid;
    }

    public IsoMetaGrid.Zone registerZone(String name, String type, int _x, int _y, int z, int width, int height) {
        return this.MetaGrid.registerZone(name, type, _x, _y, z, width, height);
    }

    public IsoMetaGrid.Zone registerZoneNoOverlap(String name, String type, int _x, int _y, int z, int width, int height) {
        return this.MetaGrid.registerZoneNoOverlap(name, type, _x, _y, z, width, height);
    }

    public void removeZonesForLotDirectory(String lotDir) {
        this.MetaGrid.removeZonesForLotDirectory(lotDir);
    }

    public BaseSoundEmitter getFreeEmitter() {
        Object object = null;
        if (this.freeEmitters.isEmpty()) {
            object = Core.SoundDisabled ? new DummySoundEmitter() : new FMODSoundEmitter();
        } else {
            object = (BaseSoundEmitter)this.freeEmitters.pop();
        }

        this.currentEmitters.add(object);
        return (BaseSoundEmitter)object;
    }

    public BaseSoundEmitter getFreeEmitter(float _x, float _y, float z) {
        BaseSoundEmitter baseSoundEmitter = this.getFreeEmitter();
        baseSoundEmitter.setPos(_x, _y, z);
        return baseSoundEmitter;
    }

    public void takeOwnershipOfEmitter(BaseSoundEmitter emitter) {
        this.currentEmitters.remove(emitter);
    }

    public void setEmitterOwner(BaseSoundEmitter emitter, IsoObject object) {
        if (emitter != null && object != null) {
            if (!this.emitterOwners.containsKey(emitter)) {
                this.emitterOwners.put(emitter, object);
            }
        }
    }

    public void returnOwnershipOfEmitter(BaseSoundEmitter emitter) {
        if (emitter != null) {
            if (!this.currentEmitters.contains(emitter) && !this.freeEmitters.contains(emitter)) {
                if (emitter.isEmpty()) {
                    FMODSoundEmitter fMODSoundEmitter = Type.tryCastTo(emitter, FMODSoundEmitter.class);
                    if (fMODSoundEmitter != null) {
                        fMODSoundEmitter.clearParameters();
                    }

                    this.freeEmitters.add(emitter);
                } else {
                    this.currentEmitters.add(emitter);
                }
            }
        }
    }

    public IsoMetaGrid.Zone registerVehiclesZone(String string0, String string1, int int0, int int1, int int2, int int3, int int4, KahluaTable kahluaTable) {
        return this.MetaGrid.registerVehiclesZone(string0, string1, int0, int1, int2, int3, int4, kahluaTable);
    }

    public IsoMetaGrid.Zone registerMannequinZone(String string0, String string1, int int0, int int1, int int2, int int3, int int4, KahluaTable kahluaTable) {
        return this.MetaGrid.registerMannequinZone(string0, string1, int0, int1, int2, int3, int4, kahluaTable);
    }

    public void registerRoomTone(String string0, String string1, int int0, int int1, int int2, int int3, int int4, KahluaTable kahluaTable) {
        this.MetaGrid.registerRoomTone(string0, string1, int0, int1, int2, int3, int4, kahluaTable);
    }

    public void registerSpawnOrigin(int int0, int int1, int int2, int int3, KahluaTable kahluaTable) {
        ZombiePopulationManager.instance.registerSpawnOrigin(int0, int1, int2, int3, kahluaTable);
    }

    public void registerWaterFlow(float _x, float _y, float flow, float speed) {
        IsoWaterFlow.addFlow(_x, _y, flow, speed);
    }

    public void registerWaterZone(float x1, float y1, float x2, float y2, float shore, float water_ground) {
        IsoWaterFlow.addZone(x1, y1, x2, y2, shore, water_ground);
    }

    public void checkVehiclesZones() {
        this.MetaGrid.checkVehiclesZones();
    }

    public void setGameMode(String mode) {
        Core.GameMode = mode;
        Core.bLastStand = "LastStand".equals(mode);
        Core.getInstance().setChallenge(false);
        Core.ChallengeID = null;
    }

    public String getGameMode() {
        return Core.GameMode;
    }

    public void setWorld(String world) {
        Core.GameSaveWorld = world.trim();
    }

    public void setMap(String world) {
        Core.GameMap = world;
    }

    public String getMap() {
        return Core.GameMap;
    }

    public void renderTerrain() {
    }

    public int getFrameNo() {
        return this.m_frameNo;
    }

    public IsoObject getItemFromXYZIndexBuffer(ByteBuffer bb) {
        int int0 = bb.getInt();
        int int1 = bb.getInt();
        int int2 = bb.getInt();
        IsoGridSquare isoGridSquare = this.CurrentCell.getGridSquare(int0, int1, int2);
        if (isoGridSquare == null) {
            return null;
        } else {
            byte _byte = bb.get();
            return _byte >= 0 && _byte < isoGridSquare.getObjects().size() ? isoGridSquare.getObjects().get(_byte) : null;
        }
    }

    public IsoWorld() {
        if (!GameServer.bServer) {
        }
    }

    private static void initMessaging() {
        if (m_setAnimationRecordingTriggerWatcher == null) {
            m_setAnimationRecordingTriggerWatcher = new zombie.PredicatedFileWatcher(
                zombie.ZomboidFileSystem.instance.getMessagingDirSub("Trigger_AnimationRecorder.xml"),
                TriggerSetAnimationRecorderFile.class,
                IsoWorld::onTrigger_setAnimationRecorderTriggerFile
            );
            zombie.DebugFileWatcher.instance.add(m_setAnimationRecordingTriggerWatcher);
        }
    }

    private static void onTrigger_setAnimationRecorderTriggerFile(TriggerSetAnimationRecorderFile triggerSetAnimationRecorderFile) {
        m_animationRecorderActive = triggerSetAnimationRecorderFile.isRecording;
        m_animationRecorderDiscard = triggerSetAnimationRecorderFile.discard;
    }

    public static boolean isAnimRecorderActive() {
        return m_animationRecorderActive;
    }

    public static boolean isAnimRecorderDiscardTriggered() {
        return m_animationRecorderDiscard;
    }

    public IsoSurvivor CreateRandomSurvivor(SurvivorDesc desc, IsoGridSquare sq, IsoPlayer player) {
        return null;
    }

    public void CreateSwarm(int num, int x1, int y1, int x2, int y2) {
    }

    public void ForceKillAllZombies() {
        zombie.GameTime.getInstance().RemoveZombiesIndiscriminate(1000);
    }

    public static int readInt(RandomAccessFile in) throws EOFException, IOException {
        int int0 = in.read();
        int int1 = in.read();
        int int2 = in.read();
        int int3 = in.read();
        if ((int0 | int1 | int2 | int3) < 0) {
            throw new EOFException();
        } else {
            return (int0 << 0) + (int1 << 8) + (int2 << 16) + (int3 << 24);
        }
    }

    public static String readString(RandomAccessFile in) throws EOFException, IOException {
        return in.readLine();
    }

    public static int readInt(InputStream in) throws EOFException, IOException {
        int int0 = in.read();
        int int1 = in.read();
        int int2 = in.read();
        int int3 = in.read();
        if ((int0 | int1 | int2 | int3) < 0) {
            throw new EOFException();
        } else {
            return (int0 << 0) + (int1 << 8) + (int2 << 16) + (int3 << 24);
        }
    }

    public static String readString(InputStream in) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        int _int = -1;
        boolean _boolean = false;

        while (!_boolean) {
            switch (_int = in.read()) {
                case -1:
                case 10:
                    _boolean = true;
                    break;
                case 13:
                    throw new IllegalStateException("\r\n unsupported");
                default:
                    stringBuilder.append((char)_int);
            }
        }

        return _int == -1 && stringBuilder.length() == 0 ? null : stringBuilder.toString();
    }

    public void LoadTileDefinitions(IsoSpriteManager sprMan, String filename, int fileNumber) {
        DebugLog.log("tiledef: loading " + filename);
        boolean boolean0 = filename.endsWith(".patch.tiles");

        try {
            FileInputStream fileInputStream = new FileInputStream(filename);

            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);

                try {
                    int int0 = readInt(bufferedInputStream);
                    int int1 = readInt(bufferedInputStream);
                    int int2 = readInt(bufferedInputStream);
                    SharedStrings sharedStrings = new SharedStrings();
                    boolean boolean1 = false;
                    boolean boolean2 = false;
                    boolean boolean3 = Core.bDebug && Translator.getLanguage() == Translator.getDefaultLanguage();
                    ArrayList arrayList0 = new ArrayList();
                    HashMap hashMap0 = new HashMap();
                    HashMap hashMap1 = new HashMap();
                    String[] string0 = new String[]{"N", "E", "S", "W"};

                    for (int int3 = 0; int3 < string0.length; int3++) {
                        hashMap1.put(string0[int3], new ArrayList());
                    }

                    ArrayList arrayList1 = new ArrayList();
                    HashMap hashMap2 = new HashMap();
                    int int4 = 0;
                    int int5 = 0;
                    int int6 = 0;
                    int int7 = 0;
                    HashSet hashSet = new HashSet();

                    for (int int8 = 0; int8 < int2; int8++) {
                        String string1 = readString(bufferedInputStream);
                        String string2 = string1.trim();
                        String string3 = readString(bufferedInputStream);
                        int int9 = readInt(bufferedInputStream);
                        int int10 = readInt(bufferedInputStream);
                        int int11 = readInt(bufferedInputStream);
                        int int12 = readInt(bufferedInputStream);

                        for (int int13 = 0; int13 < int12; int13++) {
                            IsoSprite isoSprite0;
                            if (boolean0) {
                                isoSprite0 = (IsoSprite)sprMan.NamedMap.get(string2 + "_" + int13);
                                if (isoSprite0 == null) {
                                    continue;
                                }
                            } else if (fileNumber < 2) {
                                isoSprite0 = sprMan.AddSprite(string2 + "_" + int13, fileNumber * 100 * 1000 + 10000 + int11 * 1000 + int13);
                            } else {
                                isoSprite0 = sprMan.AddSprite(string2 + "_" + int13, fileNumber * 512 * 512 + int11 * 512 + int13);
                            }

                            if (Core.bDebug) {
                                if (this.allTiles.containsKey(string2)) {
                                    if (!boolean0) {
                                        ((ArrayList)this.allTiles.get(string2)).add(string2 + "_" + int13);
                                    }
                                } else {
                                    ArrayList arrayList2 = new ArrayList();
                                    arrayList2.add(string2 + "_" + int13);
                                    this.allTiles.put(string2, arrayList2);
                                }
                            }

                            arrayList0.add(isoSprite0);
                            if (!boolean0) {
                                isoSprite0.setName(string2 + "_" + int13);
                                isoSprite0.tileSheetIndex = int13;
                            }

                            if (isoSprite0.name.contains("damaged") || isoSprite0.name.contains("trash_")) {
                                isoSprite0.attachedFloor = true;
                                isoSprite0.getProperties().Set("attachedFloor", "true");
                            }

                            if (isoSprite0.name.startsWith("f_bushes") && int13 <= 31) {
                                isoSprite0.isBush = true;
                                isoSprite0.attachedFloor = true;
                            }

                            int int14 = readInt(bufferedInputStream);

                            for (int int15 = 0; int15 < int14; int15++) {
                                string1 = readString(bufferedInputStream);
                                String string4 = string1.trim();
                                string1 = readString(bufferedInputStream);
                                String string5 = string1.trim();
                                IsoObjectType isoObjectType = IsoObjectType.FromString(string4);
                                if (isoObjectType != IsoObjectType.MAX) {
                                    if (isoSprite0.getType() != IsoObjectType.doorW && isoSprite0.getType() != IsoObjectType.doorN
                                        || isoObjectType != IsoObjectType.wall) {
                                        isoSprite0.setType(isoObjectType);
                                    }

                                    if (isoObjectType == IsoObjectType.doorW) {
                                        isoSprite0.getProperties().Set(IsoFlagType.doorW);
                                    } else if (isoObjectType == IsoObjectType.doorN) {
                                        isoSprite0.getProperties().Set(IsoFlagType.doorN);
                                    }
                                } else {
                                    string4 = sharedStrings.get(string4);
                                    if (string4.equals("firerequirement")) {
                                        isoSprite0.firerequirement = Integer.parseInt(string5);
                                    } else if (string4.equals("fireRequirement")) {
                                        isoSprite0.firerequirement = Integer.parseInt(string5);
                                    } else if (string4.equals("BurntTile")) {
                                        isoSprite0.burntTile = string5;
                                    } else if (string4.equals("ForceAmbient")) {
                                        isoSprite0.forceAmbient = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("solidfloor")) {
                                        isoSprite0.solidfloor = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("canBeRemoved")) {
                                        isoSprite0.canBeRemoved = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("attachedFloor")) {
                                        isoSprite0.attachedFloor = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("cutW")) {
                                        isoSprite0.cutW = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("cutN")) {
                                        isoSprite0.cutN = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("solid")) {
                                        isoSprite0.solid = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("solidTrans")) {
                                        isoSprite0.solidTrans = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("invisible")) {
                                        isoSprite0.invisible = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("alwaysDraw")) {
                                        isoSprite0.alwaysDraw = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("forceRender")) {
                                        isoSprite0.forceRender = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if ("FloorHeight".equals(string4)) {
                                        if ("OneThird".equals(string5)) {
                                            isoSprite0.getProperties().Set(IsoFlagType.FloorHeightOneThird);
                                        } else if ("TwoThirds".equals(string5)) {
                                            isoSprite0.getProperties().Set(IsoFlagType.FloorHeightTwoThirds);
                                        }
                                    } else if (string4.equals("MoveWithWind")) {
                                        isoSprite0.moveWithWind = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("WindType")) {
                                        isoSprite0.windType = Integer.parseInt(string5);
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else if (string4.equals("RenderLayer")) {
                                        isoSprite0.getProperties().Set(string4, string5);
                                        if ("Default".equals(string5)) {
                                            isoSprite0.renderLayer = 0;
                                        } else if ("Floor".equals(string5)) {
                                            isoSprite0.renderLayer = 1;
                                        }
                                    } else if (string4.equals("TreatAsWallOrder")) {
                                        isoSprite0.treatAsWallOrder = true;
                                        isoSprite0.getProperties().Set(string4, string5);
                                    } else {
                                        isoSprite0.getProperties().Set(string4, string5);
                                        if ("WindowN".equals(string4) || "WindowW".equals(string4)) {
                                            isoSprite0.getProperties().Set(string4, string5, false);
                                        }
                                    }
                                }

                                if (isoObjectType == IsoObjectType.tree) {
                                    if (isoSprite0.name.equals("e_riverbirch_1_1")) {
                                        string5 = "1";
                                    }

                                    isoSprite0.getProperties().Set("tree", string5);
                                    isoSprite0.getProperties().UnSet(IsoFlagType.solid);
                                    isoSprite0.getProperties().Set(IsoFlagType.blocksight);
                                    int int16 = Integer.parseInt(string5);
                                    if (string2.startsWith("vegetation_trees")) {
                                        int16 = 4;
                                    }

                                    if (int16 < 1) {
                                        int16 = 1;
                                    }

                                    if (int16 > 4) {
                                        int16 = 4;
                                    }

                                    if (int16 == 1 || int16 == 2) {
                                        isoSprite0.getProperties().UnSet(IsoFlagType.blocksight);
                                    }
                                }

                                if (string4.equals("interior") && string5.equals("false")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.exterior);
                                }

                                if (string4.equals("HoppableN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                }

                                if (string4.equals("HoppableW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                }

                                if (string4.equals("WallN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("WallN", "", false);
                                }

                                if (string4.equals("CantClimb")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.CantClimb);
                                } else if (string4.equals("container")) {
                                    isoSprite0.getProperties().Set(string4, string5, false);
                                } else if (string4.equals("WallNTrans")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("WallNTrans", "", false);
                                } else if (string4.equals("WallW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                    isoSprite0.getProperties().Set("WallW", "", false);
                                } else if (string4.equals("windowN")) {
                                    isoSprite0.getProperties().Set("WindowN", "WindowN");
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.getProperties().Set("WindowN", "WindowN", false);
                                } else if (string4.equals("windowW")) {
                                    isoSprite0.getProperties().Set("WindowW", "WindowW");
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.getProperties().Set("WindowW", "WindowW", false);
                                } else if (string4.equals("cutW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.cutW = true;
                                } else if (string4.equals("cutN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.cutN = true;
                                } else if (string4.equals("WallWTrans")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                    isoSprite0.getProperties().Set("WallWTrans", "", false);
                                } else if (string4.equals("DoorWallN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("DoorWallN", "", false);
                                } else if (string4.equals("DoorWallNTrans")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("DoorWallNTrans", "", false);
                                } else if (string4.equals("DoorWallW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.cutW = true;
                                    isoSprite0.getProperties().Set("DoorWallW", "", false);
                                } else if (string4.equals("DoorWallWTrans")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.cutW = true;
                                    isoSprite0.getProperties().Set("DoorWallWTrans", "", false);
                                } else if (string4.equals("WallNW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("WallNW", "", false);
                                } else if (string4.equals("WallNWTrans")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                    isoSprite0.cutN = true;
                                    isoSprite0.getProperties().Set("WallNWTrans", "", false);
                                } else if (string4.equals("WallSE")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.getProperties().Set(IsoFlagType.WallSE);
                                    isoSprite0.getProperties().Set("WallSE", "WallSE");
                                    isoSprite0.cutW = true;
                                } else if (string4.equals("WindowW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathW);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.setType(IsoObjectType.windowFW);
                                    if (isoSprite0.getProperties().Is(IsoFlagType.HoppableW)) {
                                        if (Core.bDebug) {
                                            DebugLog.log("ERROR: WindowW sprite shouldn't have HoppableW (" + isoSprite0.getName() + ")");
                                        }

                                        isoSprite0.getProperties().UnSet(IsoFlagType.HoppableW);
                                    }

                                    isoSprite0.cutW = true;
                                } else if (string4.equals("WindowN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.setType(IsoObjectType.windowFN);
                                    if (isoSprite0.getProperties().Is(IsoFlagType.HoppableN)) {
                                        if (Core.bDebug) {
                                            DebugLog.log("ERROR: WindowN sprite shouldn't have HoppableN (" + isoSprite0.getName() + ")");
                                        }

                                        isoSprite0.getProperties().UnSet(IsoFlagType.HoppableN);
                                    }

                                    isoSprite0.cutN = true;
                                } else if (string4.equals("UnbreakableWindowW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathW);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentW);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                } else if (string4.equals("UnbreakableWindowN")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.canPathN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutN = true;
                                } else if (string4.equals("UnbreakableWindowNW")) {
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.transparentN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideN);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutN);
                                    isoSprite0.getProperties().Set(IsoFlagType.collideW);
                                    isoSprite0.getProperties().Set(IsoFlagType.cutW);
                                    isoSprite0.setType(IsoObjectType.wall);
                                    isoSprite0.cutW = true;
                                    isoSprite0.cutN = true;
                                } else if ("NoWallLighting".equals(string4)) {
                                    isoSprite0.getProperties().Set(IsoFlagType.NoWallLighting);
                                } else if ("ForceAmbient".equals(string4)) {
                                    isoSprite0.getProperties().Set(IsoFlagType.ForceAmbient);
                                }

                                if (string4.equals("name")) {
                                    isoSprite0.setParentObjectName(string5);
                                }
                            }

                            if (isoSprite0.getProperties().Is("lightR") || isoSprite0.getProperties().Is("lightG") || isoSprite0.getProperties().Is("lightB")) {
                                if (!isoSprite0.getProperties().Is("lightR")) {
                                    isoSprite0.getProperties().Set("lightR", "0");
                                }

                                if (!isoSprite0.getProperties().Is("lightG")) {
                                    isoSprite0.getProperties().Set("lightG", "0");
                                }

                                if (!isoSprite0.getProperties().Is("lightB")) {
                                    isoSprite0.getProperties().Set("lightB", "0");
                                }
                            }

                            isoSprite0.getProperties().CreateKeySet();
                            if (Core.bDebug && isoSprite0.getProperties().Is("SmashedTileOffset") && !isoSprite0.getProperties().Is("GlassRemovedOffset")) {
                                DebugLog.General.error("Window sprite has SmashedTileOffset but no GlassRemovedOffset (" + isoSprite0.getName() + ")");
                            }
                        }

                        this.setOpenDoorProperties(string2, arrayList0);
                        hashMap0.clear();

                        for (IsoSprite isoSprite1 : arrayList0) {
                            if (isoSprite1.getProperties().Is("StopCar")) {
                                isoSprite1.setType(IsoObjectType.isMoveAbleObject);
                            }

                            if (isoSprite1.getProperties().Is("IsMoveAble")) {
                                if (isoSprite1.getProperties().Is("CustomName") && !isoSprite1.getProperties().Val("CustomName").equals("")) {
                                    int4++;
                                    if (isoSprite1.getProperties().Is("GroupName")) {
                                        String string6 = isoSprite1.getProperties().Val("GroupName") + " " + isoSprite1.getProperties().Val("CustomName");
                                        if (!hashMap0.containsKey(string6)) {
                                            hashMap0.put(string6, new ArrayList());
                                        }

                                        ((ArrayList)hashMap0.get(string6)).add(isoSprite1);
                                        hashSet.add(string6);
                                    } else {
                                        if (!hashMap2.containsKey(string2)) {
                                            hashMap2.put(string2, new ArrayList());
                                        }

                                        if (!((ArrayList)hashMap2.get(string2)).contains(isoSprite1.getProperties().Val("CustomName"))) {
                                            ((ArrayList)hashMap2.get(string2)).add(isoSprite1.getProperties().Val("CustomName"));
                                        }

                                        int5++;
                                        hashSet.add(isoSprite1.getProperties().Val("CustomName"));
                                    }
                                } else {
                                    DebugLog.log("[IMPORTANT] MOVABLES: Object has no custom name defined: sheet = " + string2);
                                }
                            }
                        }

                        for (Entry entry : hashMap0.entrySet()) {
                            String string7 = (String)entry.getKey();
                            if (!hashMap2.containsKey(string2)) {
                                hashMap2.put(string2, new ArrayList());
                            }

                            if (!((ArrayList)hashMap2.get(string2)).contains(string7)) {
                                ((ArrayList)hashMap2.get(string2)).add(string7);
                            }

                            ArrayList arrayList3 = (ArrayList)entry.getValue();
                            if (arrayList3.size() == 1) {
                                DebugLog.log("MOVABLES: Object has only one face defined for group: (" + string7 + ") sheet = " + string2);
                            }

                            if (arrayList3.size() == 3) {
                                DebugLog.log(
                                    "MOVABLES: Object only has 3 sprites, _might_ have a error in settings, group: (" + string7 + ") sheet = " + string2
                                );
                            }

                            for (String string8 : string0) {
                                ((ArrayList)hashMap1.get(string8)).clear();
                            }

                            boolean boolean4 = ((IsoSprite)arrayList3.get(0)).getProperties().Is("SpriteGridPos")
                                && !((IsoSprite)arrayList3.get(0)).getProperties().Val("SpriteGridPos").equals("None");
                            boolean boolean5 = true;

                            for (IsoSprite isoSprite2 : arrayList3) {
                                boolean boolean6 = isoSprite2.getProperties().Is("SpriteGridPos")
                                    && !isoSprite2.getProperties().Val("SpriteGridPos").equals("None");
                                if (boolean4 != boolean6) {
                                    boolean5 = false;
                                    DebugLog.log("MOVABLES: Difference in SpriteGrid settings for members of group: (" + string7 + ") sheet = " + string2);
                                    break;
                                }

                                if (!isoSprite2.getProperties().Is("Facing")) {
                                    boolean5 = false;
                                } else {
                                    String string9 = isoSprite2.getProperties().Val("Facing");
                                    switch (string9) {
                                        case "N":
                                            ((ArrayList)hashMap1.get("N")).add(isoSprite2);
                                            break;
                                        case "E":
                                            ((ArrayList)hashMap1.get("E")).add(isoSprite2);
                                            break;
                                        case "S":
                                            ((ArrayList)hashMap1.get("S")).add(isoSprite2);
                                            break;
                                        case "W":
                                            ((ArrayList)hashMap1.get("W")).add(isoSprite2);
                                            break;
                                        default:
                                            DebugLog.log(
                                                "MOVABLES: Invalid face ("
                                                    + isoSprite2.getProperties().Val("Facing")
                                                    + ") for group: ("
                                                    + string7
                                                    + ") sheet = "
                                                    + string2
                                            );
                                            boolean5 = false;
                                    }
                                }

                                if (!boolean5) {
                                    DebugLog.log("MOVABLES: Not all members have a valid face defined for group: (" + string7 + ") sheet = " + string2);
                                    break;
                                }
                            }

                            if (boolean5) {
                                if (boolean4) {
                                    int int17 = 0;
                                    IsoSpriteGrid[] isoSpriteGrid0 = new IsoSpriteGrid[string0.length];

                                    label676:
                                    for (int int18 = 0; int18 < string0.length; int18++) {
                                        ArrayList arrayList4 = (ArrayList)hashMap1.get(string0[int18]);
                                        if (arrayList4.size() > 0) {
                                            if (int17 == 0) {
                                                int17 = arrayList4.size();
                                            }

                                            if (int17 != arrayList4.size()) {
                                                DebugLog.log(
                                                    "MOVABLES: Sprite count mismatch for multi sprite movable, group: (" + string7 + ") sheet = " + string2
                                                );
                                                boolean5 = false;
                                                break;
                                            }

                                            arrayList1.clear();
                                            int int19 = -1;
                                            int int20 = -1;
                                            Iterator iterator = arrayList4.iterator();

                                            while (true) {
                                                if (iterator.hasNext()) {
                                                    IsoSprite isoSprite3 = (IsoSprite)iterator.next();
                                                    String string10 = isoSprite3.getProperties().Val("SpriteGridPos");
                                                    if (!arrayList1.contains(string10)) {
                                                        arrayList1.add(string10);
                                                        String[] string11 = string10.split(",");
                                                        if (string11.length == 2) {
                                                            int int21 = Integer.parseInt(string11[0]);
                                                            int int22 = Integer.parseInt(string11[1]);
                                                            if (int21 > int19) {
                                                                int19 = int21;
                                                            }

                                                            if (int22 > int20) {
                                                                int20 = int22;
                                                            }
                                                            continue;
                                                        }

                                                        DebugLog.log(
                                                            "MOVABLES: SpriteGrid position error for multi sprite movable, group: ("
                                                                + string7
                                                                + ") sheet = "
                                                                + string2
                                                        );
                                                        boolean5 = false;
                                                    } else {
                                                        DebugLog.log(
                                                            "MOVABLES: double SpriteGrid position ("
                                                                + string10
                                                                + ") for multi sprite movable, group: ("
                                                                + string7
                                                                + ") sheet = "
                                                                + string2
                                                        );
                                                        boolean5 = false;
                                                    }
                                                }

                                                if (int19 == -1 || int20 == -1 || (int19 + 1) * (int20 + 1) != arrayList4.size()) {
                                                    DebugLog.log(
                                                        "MOVABLES: SpriteGrid dimensions error for multi sprite movable, group: ("
                                                            + string7
                                                            + ") sheet = "
                                                            + string2
                                                    );
                                                    boolean5 = false;
                                                    break label676;
                                                }

                                                if (!boolean5) {
                                                    break label676;
                                                }

                                                isoSpriteGrid0[int18] = new IsoSpriteGrid(int19 + 1, int20 + 1);

                                                for (IsoSprite isoSprite4 : arrayList4) {
                                                    String string12 = isoSprite4.getProperties().Val("SpriteGridPos");
                                                    String[] string13 = string12.split(",");
                                                    int int23 = Integer.parseInt(string13[0]);
                                                    int int24 = Integer.parseInt(string13[1]);
                                                    isoSpriteGrid0[int18].setSprite(int23, int24, isoSprite4);
                                                }

                                                if (!isoSpriteGrid0[int18].validate()) {
                                                    DebugLog.log(
                                                        "MOVABLES: SpriteGrid didn't validate for multi sprite movable, group: ("
                                                            + string7
                                                            + ") sheet = "
                                                            + string2
                                                    );
                                                    boolean5 = false;
                                                    break label676;
                                                }
                                                break;
                                            }
                                        }
                                    }

                                    if (boolean5 && int17 != 0) {
                                        int7++;

                                        for (int int25 = 0; int25 < string0.length; int25++) {
                                            IsoSpriteGrid isoSpriteGrid1 = isoSpriteGrid0[int25];
                                            if (isoSpriteGrid1 != null) {
                                                for (IsoSprite isoSprite5 : isoSpriteGrid1.getSprites()) {
                                                    isoSprite5.setSpriteGrid(isoSpriteGrid1);

                                                    for (int int26 = 0; int26 < string0.length; int26++) {
                                                        if (int26 != int25 && isoSpriteGrid0[int26] != null) {
                                                            isoSprite5.getProperties()
                                                                .Set(
                                                                    string0[int26] + "offset",
                                                                    Integer.toString(
                                                                        arrayList0.indexOf(isoSpriteGrid0[int26].getAnchorSprite())
                                                                            - arrayList0.indexOf(isoSprite5)
                                                                    )
                                                                );
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else {
                                        DebugLog.log("MOVABLES: Error in multi sprite movable, group: (" + string7 + ") sheet = " + string2);
                                    }
                                } else if (arrayList3.size() > 4) {
                                    DebugLog.log("MOVABLES: Object has too many faces defined for group: (" + string7 + ") sheet = " + string2);
                                } else {
                                    for (String string14 : string0) {
                                        if (((ArrayList)hashMap1.get(string14)).size() > 1) {
                                            DebugLog.log(
                                                "MOVABLES: " + string14 + " face defined more than once for group: (" + string7 + ") sheet = " + string2
                                            );
                                            boolean5 = false;
                                        }
                                    }

                                    if (boolean5) {
                                        int6++;

                                        for (IsoSprite isoSprite6 : arrayList3) {
                                            for (String string15 : string0) {
                                                ArrayList arrayList5 = (ArrayList)hashMap1.get(string15);
                                                if (arrayList5.size() > 0 && arrayList5.get(0) != isoSprite6) {
                                                    isoSprite6.getProperties()
                                                        .Set(
                                                            string15 + "offset",
                                                            Integer.toString(arrayList0.indexOf(arrayList5.get(0)) - arrayList0.indexOf(isoSprite6))
                                                        );
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        arrayList0.clear();
                    }

                    if (boolean2) {
                        ArrayList arrayList6 = new ArrayList(hashSet);
                        Collections.sort(arrayList6);

                        for (String string16 : arrayList6) {
                            System.out
                                .println(
                                    string16.replaceAll(" ", "_").replaceAll("-", "_").replaceAll("'", "").replaceAll("\\.", "") + " = \"" + string16 + "\","
                                );
                        }
                    }

                    if (boolean3) {
                        ArrayList arrayList7 = new ArrayList(hashSet);
                        Collections.sort(arrayList7);
                        StringBuilder stringBuilder = new StringBuilder();

                        for (String string17 : arrayList7) {
                            if (Translator.getMoveableDisplayNameOrNull(string17) == null) {
                                stringBuilder.append(
                                    string17.replaceAll(" ", "_").replaceAll("-", "_").replaceAll("'", "").replaceAll("\\.", "") + " = \"" + string17 + "\",\n"
                                );
                            }
                        }

                        String string18 = stringBuilder.toString();
                        if (!string18.isEmpty() && Core.bDebug) {
                            System.out.println("Missing translations in Moveables_EN.txt:\n" + string18);
                        }
                    }

                    if (boolean1) {
                        try {
                            this.saveMovableStats(hashMap2, fileNumber, int5, int6, int7, int4);
                        } catch (Exception exception0) {
                        }
                    }
                } catch (Throwable throwable0) {
                    try {
                        bufferedInputStream.close();
                    } catch (Throwable throwable1) {
                        throwable0.addSuppressed(throwable1);
                    }

                    throw throwable0;
                }

                bufferedInputStream.close();
            } catch (Throwable throwable2) {
                try {
                    fileInputStream.close();
                } catch (Throwable throwable3) {
                    throwable2.addSuppressed(throwable3);
                }

                throw throwable2;
            }

            fileInputStream.close();
        } catch (Exception exception1) {
            ExceptionLogger.logException(exception1);
        }
    }

    private void GenerateTilePropertyLookupTables() {
        TilePropertyAliasMap.instance.Generate(PropertyValueMap);
        PropertyValueMap.clear();
    }

    public void LoadTileDefinitionsPropertyStrings(IsoSpriteManager sprMan, String filename, int fileNumber) {
        DebugLog.log("tiledef: loading " + filename);
        if (!GameServer.bServer) {
            Thread.yield();
            Core.getInstance().DoFrameReady();
        }

        try {
            FileInputStream fileInputStream = new FileInputStream(filename);

            try {
                BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);

                try {
                    int int0 = readInt(bufferedInputStream);
                    int int1 = readInt(bufferedInputStream);
                    int int2 = readInt(bufferedInputStream);
                    SharedStrings sharedStrings = new SharedStrings();

                    for (int int3 = 0; int3 < int2; int3++) {
                        String string0 = readString(bufferedInputStream);
                        String string1 = string0.trim();
                        String string2 = readString(bufferedInputStream);
                        this.tileImages.add(string2);
                        int int4 = readInt(bufferedInputStream);
                        int int5 = readInt(bufferedInputStream);
                        int int6 = readInt(bufferedInputStream);
                        int int7 = readInt(bufferedInputStream);

                        for (int int8 = 0; int8 < int7; int8++) {
                            int int9 = readInt(bufferedInputStream);

                            for (int int10 = 0; int10 < int9; int10++) {
                                string0 = readString(bufferedInputStream);
                                String string3 = string0.trim();
                                string0 = readString(bufferedInputStream);
                                String string4 = string0.trim();
                                IsoObjectType isoObjectType = IsoObjectType.FromString(string3);
                                string3 = sharedStrings.get(string3);
                                ArrayList arrayList = null;
                                if (PropertyValueMap.containsKey(string3)) {
                                    arrayList = (ArrayList)PropertyValueMap.get(string3);
                                } else {
                                    arrayList = new ArrayList();
                                    PropertyValueMap.put(string3, arrayList);
                                }

                                if (!arrayList.contains(string4)) {
                                    arrayList.add(string4);
                                }
                            }
                        }
                    }
                } catch (Throwable throwable0) {
                    try {
                        bufferedInputStream.close();
                    } catch (Throwable throwable1) {
                        throwable0.addSuppressed(throwable1);
                    }

                    throw throwable0;
                }

                bufferedInputStream.close();
            } catch (Throwable throwable2) {
                try {
                    fileInputStream.close();
                } catch (Throwable throwable3) {
                    throwable2.addSuppressed(throwable3);
                }

                throw throwable2;
            }

            fileInputStream.close();
        } catch (Exception exception) {
            Logger.getLogger(zombie.GameWindow.class.getName()).log(Level.SEVERE, null, exception);
        }
    }

    private void SetCustomPropertyValues() {
        ((ArrayList)PropertyValueMap.get("WindowN")).add("WindowN");
        ((ArrayList)PropertyValueMap.get("WindowW")).add("WindowW");
        ((ArrayList)PropertyValueMap.get("DoorWallN")).add("DoorWallN");
        ((ArrayList)PropertyValueMap.get("DoorWallW")).add("DoorWallW");
        ((ArrayList)PropertyValueMap.get("WallSE")).add("WallSE");
        ArrayList arrayList = new ArrayList();

        for (int _int = -96; _int <= 96; _int++) {
            String string = Integer.toString(_int);
            arrayList.add(string);
        }

        PropertyValueMap.put("Noffset", arrayList);
        PropertyValueMap.put("Soffset", arrayList);
        PropertyValueMap.put("Woffset", arrayList);
        PropertyValueMap.put("Eoffset", arrayList);
        ((ArrayList)PropertyValueMap.get("tree")).add("5");
        ((ArrayList)PropertyValueMap.get("tree")).add("6");
        ((ArrayList)PropertyValueMap.get("lightR")).add("0");
        ((ArrayList)PropertyValueMap.get("lightG")).add("0");
        ((ArrayList)PropertyValueMap.get("lightB")).add("0");
    }

    private void setOpenDoorProperties(String string2, ArrayList<IsoSprite> arrayList) {
        for (int int0 = 0; int0 < arrayList.size(); int0++) {
            IsoSprite isoSprite0 = (IsoSprite)arrayList.get(int0);
            if ((isoSprite0.getType() == IsoObjectType.doorN || isoSprite0.getType() == IsoObjectType.doorW)
                && !isoSprite0.getProperties().Is(IsoFlagType.open)) {
                String string0 = isoSprite0.getProperties().Val("DoubleDoor");
                if (string0 != null) {
                    int int1 = PZMath.tryParseInt(string0, -1);
                    if (int1 >= 5) {
                        isoSprite0.getProperties().Set(IsoFlagType.open);
                    }
                } else {
                    String string1 = isoSprite0.getProperties().Val("GarageDoor");
                    if (string1 != null) {
                        int int2 = PZMath.tryParseInt(string1, -1);
                        if (int2 >= 4) {
                            isoSprite0.getProperties().Set(IsoFlagType.open);
                        }
                    } else {
                        IsoSprite isoSprite1 = (IsoSprite)IsoSpriteManager.instance.NamedMap.get(string2 + "_" + (isoSprite0.tileSheetIndex + 2));
                        if (isoSprite1 != null) {
                            isoSprite1.setType(isoSprite0.getType());
                            isoSprite1.getProperties().Set(isoSprite0.getType() == IsoObjectType.doorN ? IsoFlagType.doorN : IsoFlagType.doorW);
                            isoSprite1.getProperties().Set(IsoFlagType.open);
                        }
                    }
                }
            }
        }
    }

    private void saveMovableStats(Map<String, ArrayList<String>> map, int int0, int int1, int int2, int int3, int int4) throws FileNotFoundException, IOException {
        File file0 = new File(zombie.ZomboidFileSystem.instance.getCacheDir());
        if (file0.exists() && file0.isDirectory()) {
            File file1 = new File(zombie.ZomboidFileSystem.instance.getCacheDir() + File.separator + "movables_stats_" + int0 + ".txt");

            try {
                FileWriter fileWriter = new FileWriter(file1, false);

                try {
                    fileWriter.write("### Movable objects ###" + System.lineSeparator());
                    fileWriter.write("Single Face: " + int1 + System.lineSeparator());
                    fileWriter.write("Multi Face: " + int2 + System.lineSeparator());
                    fileWriter.write("Multi Face & Multi Sprite: " + int3 + System.lineSeparator());
                    fileWriter.write("Total objects : " + (int1 + int2 + int3) + System.lineSeparator());
                    fileWriter.write(" " + System.lineSeparator());
                    fileWriter.write("Total sprites : " + int4 + System.lineSeparator());
                    fileWriter.write(" " + System.lineSeparator());

                    for (Entry entry : map.entrySet()) {
                        fileWriter.write((String)entry.getKey() + System.lineSeparator());

                        for (String string : (ArrayList)entry.getValue()) {
                            fileWriter.write("\t" + string + System.lineSeparator());
                        }
                    }
                } catch (Throwable throwable0) {
                    try {
                        fileWriter.close();
                    } catch (Throwable throwable1) {
                        throwable0.addSuppressed(throwable1);
                    }

                    throw throwable0;
                }

                fileWriter.close();
            } catch (Exception exception) {
                exception.printStackTrace();
            }
        }
    }

    private void addJumboTreeTileset(IsoSpriteManager isoSpriteManager, int int5, String string1, int int4, int int1, int int6) {
        byte _byte = 2;

        for (int int0 = 0; int0 < int1; int0++) {
            for (int int2 = 0; int2 < _byte; int2++) {
                String string0 = "e_" + string1 + "JUMBO_1";
                int int3 = int0 * _byte + int2;
                IsoSprite isoSprite = isoSpriteManager.AddSprite(string0 + "_" + int3, int5 * 512 * 512 + int4 * 512 + int3);

                assert GameServer.bServer
                    || !isoSprite.CurrentAnim.Frames.isEmpty() && ((IsoDirectionFrame)isoSprite.CurrentAnim.Frames.get(0)).getTexture(IsoDirections.N) != null;

                isoSprite.setName(string0 + "_" + int3);
                isoSprite.setType(IsoObjectType.tree);
                isoSprite.getProperties().Set("tree", int2 == 0 ? "5" : "6");
                isoSprite.getProperties().UnSet(IsoFlagType.solid);
                isoSprite.getProperties().Set(IsoFlagType.blocksight);
                isoSprite.getProperties().CreateKeySet();
                isoSprite.moveWithWind = true;
                isoSprite.windType = int6;
            }
        }
    }

    private void JumboTreeDefinitions(IsoSpriteManager isoSpriteManager, int _int) {
        this.addJumboTreeTileset(isoSpriteManager, _int, "americanholly", 1, 2, 3);
        this.addJumboTreeTileset(isoSpriteManager, _int, "americanlinden", 2, 6, 2);
        this.addJumboTreeTileset(isoSpriteManager, _int, "canadianhemlock", 3, 2, 3);
        this.addJumboTreeTileset(isoSpriteManager, _int, "carolinasilverbell", 4, 6, 1);
        this.addJumboTreeTileset(isoSpriteManager, _int, "cockspurhawthorn", 5, 6, 2);
        this.addJumboTreeTileset(isoSpriteManager, _int, "dogwood", 6, 6, 2);
        this.addJumboTreeTileset(isoSpriteManager, _int, "easternredbud", 7, 6, 2);
        this.addJumboTreeTileset(isoSpriteManager, _int, "redmaple", 8, 6, 2);
        this.addJumboTreeTileset(isoSpriteManager, _int, "riverbirch", 9, 6, 1);
        this.addJumboTreeTileset(isoSpriteManager, _int, "virginiapine", 10, 2, 1);
        this.addJumboTreeTileset(isoSpriteManager, _int, "yellowwood", 11, 6, 2);
        byte byte0 = 12;
        byte byte1 = 0;
        IsoSprite isoSprite = isoSpriteManager.AddSprite("jumbo_tree_01_" + byte1, _int * 512 * 512 + byte0 * 512 + byte1);
        isoSprite.setName("jumbo_tree_01_" + byte1);
        isoSprite.setType(IsoObjectType.tree);
        isoSprite.getProperties().Set("tree", "4");
        isoSprite.getProperties().UnSet(IsoFlagType.solid);
        isoSprite.getProperties().Set(IsoFlagType.blocksight);
    }

    private void loadedTileDefinitions() {
        CellLoader.smashedWindowSpriteMap.clear();

        for (IsoSprite isoSprite0 : IsoSpriteManager.instance.NamedMap.values()) {
            PropertyContainer propertyContainer = isoSprite0.getProperties();
            if (propertyContainer.Is(IsoFlagType.windowW) || propertyContainer.Is(IsoFlagType.windowN)) {
                String string = propertyContainer.Val("SmashedTileOffset");
                if (string != null) {
                    int _int = PZMath.tryParseInt(string, 0);
                    if (_int != 0) {
                        IsoSprite isoSprite1 = IsoSprite.getSprite(IsoSpriteManager.instance, isoSprite0, _int);
                        if (isoSprite1 != null) {
                            CellLoader.smashedWindowSpriteMap.put(isoSprite1, isoSprite0);
                        }
                    }
                }
            }
        }
    }

    public boolean LoadPlayerForInfo() throws FileNotFoundException, IOException {
        if (GameClient.bClient) {
            return ClientPlayerDB.getInstance().loadNetworkPlayerInfo(1);
        } else {
            File file = zombie.ZomboidFileSystem.instance.getFileInCurrentSave("map_p.bin");
            if (!file.exists()) {
                PlayerDB.getInstance().importPlayersFromVehiclesDB();
                return PlayerDB.getInstance().loadLocalPlayerInfo(1);
            } else {
                FileInputStream fileInputStream = new FileInputStream(file);
                BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
                synchronized (SliceY.SliceBufferLock) {
                    SliceY.SliceBuffer.clear();
                    int int0 = bufferedInputStream.read(SliceY.SliceBuffer.array());
                    SliceY.SliceBuffer.limit(int0);
                    bufferedInputStream.close();
                    byte byte0 = SliceY.SliceBuffer.get();
                    byte byte1 = SliceY.SliceBuffer.get();
                    byte byte2 = SliceY.SliceBuffer.get();
                    byte byte3 = SliceY.SliceBuffer.get();
                    int int1 = -1;
                    if (byte0 == 80 && byte1 == 76 && byte2 == 89 && byte3 == 82) {
                        int1 = SliceY.SliceBuffer.getInt();
                    } else {
                        SliceY.SliceBuffer.rewind();
                    }

                    if (int1 >= 69) {
                        String string = zombie.GameWindow.ReadString(SliceY.SliceBuffer);
                        if (GameClient.bClient && int1 < 71) {
                            string = ServerOptions.instance.ServerPlayerID.getValue();
                        }

                        if (GameClient.bClient && !IsoPlayer.isServerPlayerIDValid(string)) {
                            GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_ServerPlayerIDMismatch");
                            GameLoadingState.playerWrongIP = true;
                            return false;
                        }
                    } else if (GameClient.bClient && ServerOptions.instance.ServerPlayerID.getValue().isEmpty()) {
                        GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_ServerPlayerIDMissing");
                        GameLoadingState.playerWrongIP = true;
                        return false;
                    }

                    WorldX = SliceY.SliceBuffer.getInt();
                    WorldY = SliceY.SliceBuffer.getInt();
                    IsoChunkMap.WorldXA = SliceY.SliceBuffer.getInt();
                    IsoChunkMap.WorldYA = SliceY.SliceBuffer.getInt();
                    IsoChunkMap.WorldZA = SliceY.SliceBuffer.getInt();
                    IsoChunkMap.WorldXA = IsoChunkMap.WorldXA + 300 * saveoffsetx;
                    IsoChunkMap.WorldYA = IsoChunkMap.WorldYA + 300 * saveoffsety;
                    IsoChunkMap.SWorldX[0] = WorldX;
                    IsoChunkMap.SWorldY[0] = WorldY;
                    IsoChunkMap.SWorldX[0] = IsoChunkMap.SWorldX[0] + 30 * saveoffsetx;
                    IsoChunkMap.SWorldY[0] = IsoChunkMap.SWorldY[0] + 30 * saveoffsety;
                    return true;
                }
            }
        }
    }

    public void init() throws FileNotFoundException, IOException, WorldDictionaryException {
        if (!Core.bTutorial) {
            this.randomizedBuildingList.add(new RBSafehouse());
            this.randomizedBuildingList.add(new RBBurnt());
            this.randomizedBuildingList.add(new RBOther());
            this.randomizedBuildingList.add(new RBLooted());
            this.randomizedBuildingList.add(new RBBurntFireman());
            this.randomizedBuildingList.add(new RBBurntCorpse());
            this.randomizedBuildingList.add(new RBShopLooted());
            this.randomizedBuildingList.add(new RBKateAndBaldspot());
            this.randomizedBuildingList.add(new RBStripclub());
            this.randomizedBuildingList.add(new RBSchool());
            this.randomizedBuildingList.add(new RBSpiffo());
            this.randomizedBuildingList.add(new RBPizzaWhirled());
            this.randomizedBuildingList.add(new RBPileOCrepe());
            this.randomizedBuildingList.add(new RBCafe());
            this.randomizedBuildingList.add(new RBBar());
            this.randomizedBuildingList.add(new RBOffice());
            this.randomizedBuildingList.add(new RBHairSalon());
            this.randomizedBuildingList.add(new RBClinic());
            this.randomizedVehicleStoryList.add(new RVSUtilityVehicle());
            this.randomizedVehicleStoryList.add(new RVSConstructionSite());
            this.randomizedVehicleStoryList.add(new RVSBurntCar());
            this.randomizedVehicleStoryList.add(new RVSPoliceBlockadeShooting());
            this.randomizedVehicleStoryList.add(new RVSPoliceBlockade());
            this.randomizedVehicleStoryList.add(new RVSCarCrash());
            this.randomizedVehicleStoryList.add(new RVSAmbulanceCrash());
            this.randomizedVehicleStoryList.add(new RVSCarCrashCorpse());
            this.randomizedVehicleStoryList.add(new RVSChangingTire());
            this.randomizedVehicleStoryList.add(new RVSFlippedCrash());
            this.randomizedVehicleStoryList.add(new RVSBanditRoad());
            this.randomizedVehicleStoryList.add(new RVSTrailerCrash());
            this.randomizedVehicleStoryList.add(new RVSCrashHorde());
            this.randomizedZoneList.add(new RZSForestCamp());
            this.randomizedZoneList.add(new RZSForestCampEaten());
            this.randomizedZoneList.add(new RZSBuryingCamp());
            this.randomizedZoneList.add(new RZSBeachParty());
            this.randomizedZoneList.add(new RZSFishingTrip());
            this.randomizedZoneList.add(new RZSBBQParty());
            this.randomizedZoneList.add(new RZSHunterCamp());
            this.randomizedZoneList.add(new RZSSexyTime());
            this.randomizedZoneList.add(new RZSTrapperCamp());
            this.randomizedZoneList.add(new RZSBaseball());
            this.randomizedZoneList.add(new RZSMusicFestStage());
            this.randomizedZoneList.add(new RZSMusicFest());
        }

        zombie.randomizedWorld.randomizedBuilding.RBBasic.getUniqueRDSSpawned().clear();
        if (!GameClient.bClient && !GameServer.bServer) {
            BodyDamageSync.instance = null;
        } else {
            BodyDamageSync.instance = new BodyDamageSync();
        }

        if (GameServer.bServer) {
            Core.GameSaveWorld = GameServer.ServerName;
            String string0 = zombie.ZomboidFileSystem.instance.getCurrentSaveDir();
            File file0 = new File(string0);
            if (!file0.exists()) {
                GameServer.ResetID = Rand.Next(10000000);
                ServerOptions.instance.putSaveOption("ResetID", String.valueOf(GameServer.ResetID));
            }

            LuaManager.GlobalObject.createWorld(Core.GameSaveWorld);
        }

        SavedWorldVersion = this.readWorldVersion();
        if (!GameServer.bServer) {
            File file1 = zombie.ZomboidFileSystem.instance.getFileInCurrentSave("map_ver.bin");

            try {
                FileInputStream fileInputStream = new FileInputStream(file1);

                try {
                    DataInputStream dataInputStream = new DataInputStream(fileInputStream);

                    try {
                        int int0 = dataInputStream.readInt();
                        if (int0 >= 25) {
                            String string1 = zombie.GameWindow.ReadString(dataInputStream);
                            if (!GameClient.bClient) {
                                Core.GameMap = string1;
                            }
                        }

                        if (int0 >= 74) {
                            this.setDifficulty(zombie.GameWindow.ReadString(dataInputStream));
                        }
                    } catch (Throwable throwable0) {
                        try {
                            dataInputStream.close();
                        } catch (Throwable throwable1) {
                            throwable0.addSuppressed(throwable1);
                        }

                        throw throwable0;
                    }

                    dataInputStream.close();
                } catch (Throwable throwable2) {
                    try {
                        fileInputStream.close();
                    } catch (Throwable throwable3) {
                        throwable2.addSuppressed(throwable3);
                    }

                    throw throwable2;
                }

                fileInputStream.close();
            } catch (FileNotFoundException fileNotFoundException) {
            }
        }

        if (!GameServer.bServer || !GameServer.bSoftReset) {
            this.MetaGrid.CreateStep1();
        }

        LuaEventManager.triggerEvent("OnPreDistributionMerge");
        LuaEventManager.triggerEvent("OnDistributionMerge");
        LuaEventManager.triggerEvent("OnPostDistributionMerge");
        ItemPickerJava.Parse();
        VehiclesDB2.instance.init();
        LuaEventManager.triggerEvent("OnInitWorld");
        if (!GameClient.bClient) {
            zombie.SandboxOptions.instance.load();
        }

        this.bHydroPowerOn = zombie.GameTime.getInstance().NightsSurvived < zombie.SandboxOptions.getInstance().getElecShutModifier();
        zombie.ZomboidGlobals.toLua();
        ItemPickerJava.InitSandboxLootSettings();
        this.SurvivorDescriptors.clear();
        IsoSpriteManager.instance.Dispose();
        if (GameClient.bClient && ServerOptions.instance.DoLuaChecksum.getValue()) {
            try {
                NetChecksum.comparer.beginCompare();
                GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_Checksum");
                long long0 = System.currentTimeMillis();
                long long1 = long0;

                while (!GameClient.checksumValid) {
                    if (zombie.GameWindow.bServerDisconnected) {
                        return;
                    }

                    if (System.currentTimeMillis() > long0 + 8000L) {
                        DebugLog.log("checksum: timed out waiting for the server to respond");
                        GameClient.connection.forceDisconnect("world-timeout-response");
                        zombie.GameWindow.bServerDisconnected = true;
                        zombie.GameWindow.kickReason = Translator.getText("UI_GameLoad_TimedOut");
                        return;
                    }

                    if (System.currentTimeMillis() > long1 + 1000L) {
                        DebugLog.log("checksum: waited one second");
                        long1 += 1000L;
                    }

                    NetChecksum.comparer.update();
                    if (GameClient.checksumValid) {
                        break;
                    }

                    Thread.sleep(100L);
                }
            } catch (Exception exception0) {
                exception0.printStackTrace();
            }
        }

        GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_LoadTileDef");
        IsoSpriteManager isoSpriteManager = IsoSpriteManager.instance;
        this.tileImages.clear();
        zombie.ZomboidFileSystem zomboidFileSystem = zombie.ZomboidFileSystem.instance;
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions.tiles"), 0);
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("newtiledefinitions.tiles"), 1);
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_erosion.tiles"), 2);
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_apcom.tiles"), 3);
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_overlays.tiles"), 4);
        this.LoadTileDefinitionsPropertyStrings(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_noiseworks.patch.tiles"), -1);
        zombie.ZomboidFileSystem.instance.loadModTileDefPropertyStrings();
        this.SetCustomPropertyValues();
        this.GenerateTilePropertyLookupTables();
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions.tiles"), 0);
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("newtiledefinitions.tiles"), 1);
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_erosion.tiles"), 2);
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_apcom.tiles"), 3);
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_overlays.tiles"), 4);
        this.LoadTileDefinitions(isoSpriteManager, zomboidFileSystem.getMediaPath("tiledefinitions_noiseworks.patch.tiles"), -1);
        this.JumboTreeDefinitions(isoSpriteManager, 5);
        zombie.ZomboidFileSystem.instance.loadModTileDefs();
        GameLoadingState.GameLoadingString = "";
        isoSpriteManager.AddSprite("media/ui/missing-tile.png");
        LuaEventManager.triggerEvent("OnLoadedTileDefinitions", isoSpriteManager);
        this.loadedTileDefinitions();
        if (GameServer.bServer && GameServer.bSoftReset) {
            WorldConverter.instance.softreset();
        }

        try {
            WeatherFxMask.init();
        } catch (Exception exception1) {
            System.out.print(exception1.getStackTrace());
        }

        TemplateText.Initialize();
        IsoRegions.init();
        ObjectRenderEffects.init();
        WorldConverter.instance.convert(Core.GameSaveWorld, isoSpriteManager);
        if (!GameLoadingState.build23Stop) {
            zombie.SandboxOptions.instance.handleOldZombiesFile2();
            zombie.GameTime.getInstance().init();
            zombie.GameTime.getInstance().load();
            ImprovedFog.init();
            ZomboidRadio.getInstance().Init(SavedWorldVersion);
            GlobalModData.instance.init();
            if (GameServer.bServer && Core.getInstance().getPoisonousBerry() == null) {
                Core.getInstance().initPoisonousBerry();
            }

            if (GameServer.bServer && Core.getInstance().getPoisonousMushroom() == null) {
                Core.getInstance().initPoisonousMushroom();
            }

            ErosionGlobals.Boot(isoSpriteManager);
            WorldDictionary.init();
            WorldMarkers.instance.init();
            if (GameServer.bServer) {
                zombie.SharedDescriptors.initSharedDescriptors();
            }

            zombie.PersistentOutfits.instance.init();
            zombie.VirtualZombieManager.instance.init();
            VehicleIDMap.instance.Reset();
            VehicleManager.instance = new VehicleManager();
            GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_InitMap");
            this.MetaGrid.CreateStep2();
            ClimateManager.getInstance().init(this.MetaGrid);
            SafeHouse.init();
            if (!GameClient.bClient) {
                StashSystem.init();
            }

            LuaEventManager.triggerEvent("OnLoadMapZones");
            this.MetaGrid.load();
            this.MetaGrid.loadZones();
            this.MetaGrid.processZones();
            LuaEventManager.triggerEvent("OnLoadedMapZones");
            if (GameServer.bServer) {
                ServerMap.instance.init(this.MetaGrid);
            }

            int int1 = 0;
            int int2 = 0;
            if (GameClient.bClient) {
                if (ClientPlayerDB.getInstance().clientLoadNetworkPlayer() && ClientPlayerDB.getInstance().isAliveMainNetworkPlayer()) {
                    int2 = 1;
                }
            } else {
                int2 = PlayerDBHelper.isPlayerAlive(zombie.ZomboidFileSystem.instance.getCurrentSaveDir(), 1);
            }

            if (GameServer.bServer) {
                ServerPlayerDB.setAllow(true);
            }

            if (!GameClient.bClient && !GameServer.bServer) {
                PlayerDB.setAllow(true);
            }

            int int3 = 0;
            int int4 = 0;
            int int5 = 0;
            if (int2) {
                int1 = (boolean)1;
                if (!this.LoadPlayerForInfo()) {
                    return;
                }

                WorldX = IsoChunkMap.SWorldX[IsoPlayer.getPlayerIndex()];
                WorldY = IsoChunkMap.SWorldY[IsoPlayer.getPlayerIndex()];
                int3 = IsoChunkMap.WorldXA;
                int4 = IsoChunkMap.WorldYA;
                int5 = IsoChunkMap.WorldZA;
            } else {
                int1 = (boolean)0;
                if (GameClient.bClient && !ServerOptions.instance.SpawnPoint.getValue().isEmpty()) {
                    String[] string2 = ServerOptions.instance.SpawnPoint.getValue().split(",");
                    if (string2.length == 3) {
                        try {
                            IsoChunkMap.MPWorldXA = new Integer(string2[0].trim());
                            IsoChunkMap.MPWorldYA = new Integer(string2[1].trim());
                            IsoChunkMap.MPWorldZA = new Integer(string2[2].trim());
                        } catch (NumberFormatException numberFormatException0) {
                            DebugLog.log("ERROR: SpawnPoint must be x,y,z, got \"" + ServerOptions.instance.SpawnPoint.getValue() + "\"");
                            IsoChunkMap.MPWorldXA = 0;
                            IsoChunkMap.MPWorldYA = 0;
                            IsoChunkMap.MPWorldZA = 0;
                        }
                    } else {
                        DebugLog.log("ERROR: SpawnPoint must be x,y,z, got \"" + ServerOptions.instance.SpawnPoint.getValue() + "\"");
                    }
                }

                if (this.getLuaSpawnCellX() >= 0 && (!GameClient.bClient || IsoChunkMap.MPWorldXA == 0 && IsoChunkMap.MPWorldYA == 0)) {
                    IsoChunkMap.WorldXA = this.getLuaPosX() + 300 * this.getLuaSpawnCellX();
                    IsoChunkMap.WorldYA = this.getLuaPosY() + 300 * this.getLuaSpawnCellY();
                    IsoChunkMap.WorldZA = this.getLuaPosZ();
                    if (GameClient.bClient && ServerOptions.instance.SafehouseAllowRespawn.getValue()) {
                        for (int int6 = 0; int6 < SafeHouse.getSafehouseList().size(); int6++) {
                            SafeHouse safeHouse0 = (SafeHouse)SafeHouse.getSafehouseList().get(int6);
                            if (safeHouse0.getPlayers().contains(GameClient.username) && safeHouse0.isRespawnInSafehouse(GameClient.username)) {
                                IsoChunkMap.WorldXA = safeHouse0.getX() + safeHouse0.getH() / 2;
                                IsoChunkMap.WorldYA = safeHouse0.getY() + safeHouse0.getW() / 2;
                                IsoChunkMap.WorldZA = 0;
                            }
                        }
                    }

                    WorldX = IsoChunkMap.WorldXA / 10;
                    WorldY = IsoChunkMap.WorldYA / 10;
                } else if (GameClient.bClient) {
                    IsoChunkMap.WorldXA = IsoChunkMap.MPWorldXA;
                    IsoChunkMap.WorldYA = IsoChunkMap.MPWorldYA;
                    IsoChunkMap.WorldZA = IsoChunkMap.MPWorldZA;
                    WorldX = IsoChunkMap.WorldXA / 10;
                    WorldY = IsoChunkMap.WorldYA / 10;
                }
            }

            Core.getInstance();
            KahluaTable kahluaTable0 = (KahluaTable)LuaManager.env.rawget("selectedDebugScenario");
            if (kahluaTable0 != null) {
                KahluaTable kahluaTable1 = (KahluaTable)kahluaTable0.rawget("startLoc");
                int int7 = ((Double)kahluaTable1.rawget("x")).intValue();
                int int8 = ((Double)kahluaTable1.rawget("y")).intValue();
                int int9 = ((Double)kahluaTable1.rawget("z")).intValue();
                IsoChunkMap.WorldXA = int7;
                IsoChunkMap.WorldYA = int8;
                IsoChunkMap.WorldZA = int9;
                WorldX = IsoChunkMap.WorldXA / 10;
                WorldY = IsoChunkMap.WorldYA / 10;
            }

            zombie.MapCollisionData.instance.init(instance.getMetaGrid());
            ZombiePopulationManager.instance.init(instance.getMetaGrid());
            PolygonalMap2.instance.init(instance.getMetaGrid());
            GlobalObjectLookup.init(instance.getMetaGrid());
            if (!GameServer.bServer) {
                SpawnPoints.instance.initSinglePlayer();
            }

            WorldStreamer.instance.create();
            this.CurrentCell = CellLoader.LoadCellBinaryChunk(isoSpriteManager, WorldX, WorldY);
            ClimateManager.getInstance().postCellLoadSetSnow();
            GameLoadingState.GameLoadingString = Translator.getText("IGUI_MP_LoadWorld");
            zombie.MapCollisionData.instance.start();
            MapItem.LoadWorldMap();

            while (WorldStreamer.instance.isBusy()) {
                try {
                    Thread.sleep(100L);
                } catch (InterruptedException interruptedException) {
                    interruptedException.printStackTrace();
                }
            }

            ArrayList arrayList = new ArrayList();
            arrayList.addAll(IsoChunk.loadGridSquare);

            for (IsoChunk isoChunk : arrayList) {
                this.CurrentCell.ChunkMap[0].setChunkDirect(isoChunk, false);
            }

            IsoChunk.bDoServerRequests = true;
            if (int1 && zombie.SystemDisabler.doPlayerCreation) {
                this.CurrentCell.LoadPlayer(SavedWorldVersion);
                if (GameClient.bClient) {
                    IsoPlayer.getInstance().setUsername(GameClient.username);
                }

                ZomboidRadio.getInstance().getRecordedMedia().handleLegacyListenedLines(IsoPlayer.getInstance());
            } else {
                ZomboidRadio.getInstance().getRecordedMedia().handleLegacyListenedLines(null);
                IsoGridSquare isoGridSquare0 = null;
                if (IsoPlayer.numPlayers == 0) {
                    IsoPlayer.numPlayers = 1;
                }

                int int10 = IsoChunkMap.WorldXA;
                int int11 = IsoChunkMap.WorldYA;
                int int12 = IsoChunkMap.WorldZA;
                if (GameClient.bClient && !ServerOptions.instance.SpawnPoint.getValue().isEmpty()) {
                    String[] string3 = ServerOptions.instance.SpawnPoint.getValue().split(",");
                    if (string3.length != 3) {
                        DebugLog.log("ERROR: SpawnPoint must be x,y,z, got \"" + ServerOptions.instance.SpawnPoint.getValue() + "\"");
                    } else {
                        try {
                            int int13 = new Integer(string3[0].trim());
                            int int14 = new Integer(string3[1].trim());
                            int int15 = new Integer(string3[2].trim());
                            if (GameClient.bClient && ServerOptions.instance.SafehouseAllowRespawn.getValue()) {
                                for (int int16 = 0; int16 < SafeHouse.getSafehouseList().size(); int16++) {
                                    SafeHouse safeHouse1 = (SafeHouse)SafeHouse.getSafehouseList().get(int16);
                                    if (safeHouse1.getPlayers().contains(GameClient.username) && safeHouse1.isRespawnInSafehouse(GameClient.username)) {
                                        int13 = safeHouse1.getX() + safeHouse1.getH() / 2;
                                        int14 = safeHouse1.getY() + safeHouse1.getW() / 2;
                                        int15 = 0;
                                    }
                                }
                            }

                            if (this.CurrentCell.getGridSquare(int13, int14, int15) != null) {
                                int10 = int13;
                                int11 = int14;
                                int12 = int15;
                            }
                        } catch (NumberFormatException numberFormatException1) {
                            DebugLog.log("ERROR: SpawnPoint must be x,y,z, got \"" + ServerOptions.instance.SpawnPoint.getValue() + "\"");
                        }
                    }
                }

                isoGridSquare0 = this.CurrentCell.getGridSquare(int10, int11, int12);
                if (zombie.SystemDisabler.doPlayerCreation && !GameServer.bServer) {
                    if (isoGridSquare0 != null && isoGridSquare0.isFree(false) && isoGridSquare0.getRoom() != null) {
                        IsoGridSquare isoGridSquare1 = isoGridSquare0;
                        isoGridSquare0 = isoGridSquare0.getRoom().getFreeTile();
                        if (isoGridSquare0 == null) {
                            isoGridSquare0 = isoGridSquare1;
                        }
                    }

                    IsoPlayer isoPlayer0 = null;
                    if (this.getLuaPlayerDesc() != null) {
                        if (GameClient.bClient && ServerOptions.instance.SafehouseAllowRespawn.getValue()) {
                            isoGridSquare0 = this.CurrentCell.getGridSquare(IsoChunkMap.WorldXA, IsoChunkMap.WorldYA, IsoChunkMap.WorldZA);
                            if (isoGridSquare0 != null && isoGridSquare0.isFree(false) && isoGridSquare0.getRoom() != null) {
                                IsoGridSquare isoGridSquare2 = isoGridSquare0;
                                isoGridSquare0 = isoGridSquare0.getRoom().getFreeTile();
                                if (isoGridSquare0 == null) {
                                    isoGridSquare0 = isoGridSquare2;
                                }
                            }
                        }

                        if (isoGridSquare0 == null) {
                            throw new RuntimeException("can't create player at x,y,z=" + int10 + "," + int11 + "," + int12 + " because the square is null");
                        }

                        WorldSimulation.instance.create();
                        isoPlayer0 = new IsoPlayer(
                            instance.CurrentCell, this.getLuaPlayerDesc(), isoGridSquare0.getX(), isoGridSquare0.getY(), isoGridSquare0.getZ()
                        );
                        if (GameClient.bClient) {
                            isoPlayer0.setUsername(GameClient.username);
                        }

                        isoPlayer0.setDir(IsoDirections.SE);
                        isoPlayer0.sqlID = 1;
                        IsoPlayer.players[0] = isoPlayer0;
                        IsoPlayer.setInstance(isoPlayer0);
                        IsoCamera.CamCharacter = isoPlayer0;
                    }

                    IsoPlayer isoPlayer1 = IsoPlayer.getInstance();
                    isoPlayer1.applyTraits(this.getLuaTraits());
                    ProfessionFactory.Profession profession = ProfessionFactory.getProfession(isoPlayer1.getDescriptor().getProfession());
                    if (profession != null && !profession.getFreeRecipes().isEmpty()) {
                        for (String string4 : profession.getFreeRecipes()) {
                            isoPlayer1.getKnownRecipes().add(string4);
                        }
                    }

                    for (String string5 : this.getLuaTraits()) {
                        TraitFactory.Trait trait = TraitFactory.getTrait(string5);
                        if (trait != null && !trait.getFreeRecipes().isEmpty()) {
                            for (String string6 : trait.getFreeRecipes()) {
                                isoPlayer1.getKnownRecipes().add(string6);
                            }
                        }
                    }

                    if (isoGridSquare0 != null && isoGridSquare0.getRoom() != null) {
                        isoGridSquare0.getRoom().def.setExplored(true);
                        isoGridSquare0.getRoom().building.setAllExplored(true);
                        if (!GameServer.bServer && !GameClient.bClient) {
                            ZombiePopulationManager.instance.playerSpawnedAt(isoGridSquare0.getX(), isoGridSquare0.getY(), isoGridSquare0.getZ());
                        }
                    }

                    isoPlayer1.createKeyRing();
                    if (!GameClient.bClient) {
                        Core.getInstance().initPoisonousBerry();
                        Core.getInstance().initPoisonousMushroom();
                    }

                    LuaEventManager.triggerEvent("OnNewGame", isoPlayer0, isoGridSquare0);
                }
            }

            if (PlayerDB.isAllow()) {
                PlayerDB.getInstance().m_canSavePlayers = true;
            }

            if (ClientPlayerDB.isAllow()) {
                ClientPlayerDB.getInstance().canSavePlayers = true;
            }

            TutorialManager.instance.ActiveControlZombies = false;
            zombie.ReanimatedPlayers.instance.loadReanimatedPlayers();
            if (IsoPlayer.getInstance() != null) {
                if (GameClient.bClient) {
                    int1 = (int)IsoPlayer.getInstance().getX();
                    int2 = (int)IsoPlayer.getInstance().getY();
                    int3 = (int)IsoPlayer.getInstance().getZ();

                    while (int3 > 0) {
                        IsoGridSquare isoGridSquare3 = this.CurrentCell.getGridSquare(int1, int2, int3);
                        if (isoGridSquare3 != null && isoGridSquare3.TreatAsSolidFloor()) {
                            break;
                        }

                        IsoPlayer.getInstance().setZ((float)(--int3));
                    }
                }

                IsoPlayer.getInstance()
                    .setCurrent(
                        this.CurrentCell
                            .getGridSquare((int)IsoPlayer.getInstance().getX(), (int)IsoPlayer.getInstance().getY(), (int)IsoPlayer.getInstance().getZ())
                    );
            }

            if (!this.bLoaded) {
                if (!this.CurrentCell.getBuildingList().isEmpty()) {
                }

                if (!this.bLoaded) {
                    this.PopulateCellWithSurvivors();
                }
            }

            if (IsoPlayer.players[0] != null && !this.CurrentCell.getObjectList().contains(IsoPlayer.players[0])) {
                this.CurrentCell.getObjectList().add(IsoPlayer.players[0]);
            }

            LightingThread.instance.create();
            GameLoadingState.GameLoadingString = "";
            initMessaging();
            WorldDictionary.onWorldLoaded();
        }
    }

    int readWorldVersion() {
        if (GameServer.bServer) {
            File file0 = zombie.ZomboidFileSystem.instance.getFileInCurrentSave("map_t.bin");

            try {
                FileInputStream fileInputStream0 = new FileInputStream(file0);

                label108: {
                    int int0;
                    try {
                        DataInputStream dataInputStream0 = new DataInputStream(fileInputStream0);

                        label104: {
                            try {
                                byte byte0 = dataInputStream0.readByte();
                                byte byte1 = dataInputStream0.readByte();
                                byte byte2 = dataInputStream0.readByte();
                                byte byte3 = dataInputStream0.readByte();
                                if (byte0 == 71 && byte1 == 77 && byte2 == 84 && byte3 == 77) {
                                    int0 = dataInputStream0.readInt();
                                    break label104;
                                }
                            } catch (Throwable throwable0) {
                                try {
                                    dataInputStream0.close();
                                } catch (Throwable throwable1) {
                                    throwable0.addSuppressed(throwable1);
                                }

                                throw throwable0;
                            }

                            dataInputStream0.close();
                            break label108;
                        }

                        dataInputStream0.close();
                    } catch (Throwable throwable2) {
                        try {
                            fileInputStream0.close();
                        } catch (Throwable throwable3) {
                            throwable2.addSuppressed(throwable3);
                        }

                        throw throwable2;
                    }

                    fileInputStream0.close();
                    return int0;
                }

                fileInputStream0.close();
            } catch (FileNotFoundException fileNotFoundException0) {
            } catch (IOException iOException0) {
                ExceptionLogger.logException(iOException0);
            }

            return -1;
        } else {
            File file1 = zombie.ZomboidFileSystem.instance.getFileInCurrentSave("map_ver.bin");

            try {
                FileInputStream fileInputStream1 = new FileInputStream(file1);

                int int1;
                try {
                    DataInputStream dataInputStream1 = new DataInputStream(fileInputStream1);

                    try {
                        int1 = dataInputStream1.readInt();
                    } catch (Throwable throwable4) {
                        try {
                            dataInputStream1.close();
                        } catch (Throwable throwable5) {
                            throwable4.addSuppressed(throwable5);
                        }

                        throw throwable4;
                    }

                    dataInputStream1.close();
                } catch (Throwable throwable6) {
                    try {
                        fileInputStream1.close();
                    } catch (Throwable throwable7) {
                        throwable6.addSuppressed(throwable7);
                    }

                    throw throwable6;
                }

                fileInputStream1.close();
                return int1;
            } catch (FileNotFoundException fileNotFoundException1) {
            } catch (IOException iOException1) {
                ExceptionLogger.logException(iOException1);
            }

            return -1;
        }
    }

    public ArrayList<String> getLuaTraits() {
        if (this.luatraits == null) {
            this.luatraits = new ArrayList();
        }

        return this.luatraits;
    }

    public void addLuaTrait(String trait) {
        this.getLuaTraits().add(trait);
    }

    public SurvivorDesc getLuaPlayerDesc() {
        return this.luaDesc;
    }

    public void setLuaPlayerDesc(SurvivorDesc desc) {
        this.luaDesc = desc;
    }

    public void KillCell() {
        this.helicopter.deactivate();
        zombie.CollisionManager.instance.ContactMap.clear();
        IsoDeadBody.Reset();
        zombie.FliesSound.instance.Reset();
        IsoObjectPicker.Instance.Init();
        IsoChunkMap.SharedChunks.clear();
        zombie.SoundManager.instance.StopMusic();
        zombie.WorldSoundManager.instance.KillCell();
        ZombieGroupManager.instance.Reset();
        this.CurrentCell.Dispose();
        IsoSpriteManager.instance.Dispose();
        this.CurrentCell = null;
        CellLoader.wanderRoom = null;
        IsoLot.Dispose();
        IsoGameCharacter.getSurvivorMap().clear();
        IsoPlayer.getInstance().setCurrent(null);
        IsoPlayer.getInstance().setLast(null);
        IsoPlayer.getInstance().square = null;
        RainManager.reset();
        IsoFireManager.Reset();
        ObjectAmbientEmitters.Reset();
        ZombieVocalsManager.Reset();
        IsoWaterFlow.Reset();
        this.MetaGrid.Dispose();
        instance = new IsoWorld();
    }

    public void setDrawWorld(boolean b) {
        this.bDrawWorld = b;
    }

    public void sceneCullZombies() {
        this.zombieWithModel.clear();
        this.zombieWithoutModel.clear();

        for (int int0 = 0; int0 < this.CurrentCell.getZombieList().size(); int0++) {
            IsoZombie isoZombie0 = (IsoZombie)this.CurrentCell.getZombieList().get(int0);
            boolean _boolean = false;

            for (int int1 = 0; int1 < IsoPlayer.numPlayers; int1++) {
                IsoPlayer isoPlayer = IsoPlayer.players[int1];
                if (isoPlayer != null && isoZombie0.current != null) {
                    float float0 = (float)isoZombie0.getScreenProperX(int1);
                    float float1 = (float)isoZombie0.getScreenProperY(int1);
                    if (!(float0 < -100.0F)
                        && !(float1 < -100.0F)
                        && !(float0 > (float)(Core.getInstance().getOffscreenWidth(int1) + 100))
                        && !(float1 > (float)(Core.getInstance().getOffscreenHeight(int1) + 100))
                        && (isoZombie0.getAlpha(int1) != 0.0F && isoZombie0.legsSprite.def.alpha != 0.0F || isoZombie0.current.isCouldSee(int1))) {
                        _boolean = true;
                        break;
                    }
                }
            }

            if (_boolean && isoZombie0.isCurrentState(FakeDeadZombieState.instance())) {
                _boolean = false;
            }

            if (_boolean) {
                this.zombieWithModel.add(isoZombie0);
            } else {
                this.zombieWithoutModel.add(isoZombie0);
            }
        }

        Collections.sort(this.zombieWithModel, compScoreToPlayer);
        int int2 = 0;
        int int3 = 0;
        int int4 = 0;
        short _short = 510;
        PerformanceSettings.AnimationSkip = 0;

        for (int int5 = 0; int5 < this.zombieWithModel.size(); int5++) {
            IsoZombie isoZombie1 = (IsoZombie)this.zombieWithModel.get(int5);
            if (int4 < _short) {
                if (!isoZombie1.Ghost) {
                    int3++;
                    int4++;
                    isoZombie1.setSceneCulled(false);
                    if (isoZombie1.legsSprite != null && isoZombie1.legsSprite.modelSlot != null) {
                        if (int3 > PerformanceSettings.ZombieAnimationSpeedFalloffCount) {
                            int2++;
                            int3 = 0;
                        }

                        if (int4 < PerformanceSettings.ZombieBonusFullspeedFalloff) {
                            isoZombie1.legsSprite.modelSlot.model.setInstanceSkip(int3 / PerformanceSettings.ZombieBonusFullspeedFalloff);
                            int3 = 0;
                        } else {
                            isoZombie1.legsSprite.modelSlot.model.setInstanceSkip(int2 + PerformanceSettings.AnimationSkip);
                        }

                        if (isoZombie1.legsSprite.modelSlot.model.AnimPlayer != null) {
                            if (int4 < PerformanceSettings.numberZombiesBlended) {
                                isoZombie1.legsSprite.modelSlot.model.AnimPlayer.bDoBlending = !isoZombie1.isAlphaAndTargetZero(0)
                                    || !isoZombie1.isAlphaAndTargetZero(1)
                                    || !isoZombie1.isAlphaAndTargetZero(2)
                                    || !isoZombie1.isAlphaAndTargetZero(3);
                            } else {
                                isoZombie1.legsSprite.modelSlot.model.AnimPlayer.bDoBlending = false;
                            }
                        }
                    }
                }
            } else {
                isoZombie1.setSceneCulled(true);
                if (isoZombie1.hasAnimationPlayer()) {
                    isoZombie1.getAnimationPlayer().bDoBlending = false;
                }
            }
        }

        for (int int6 = 0; int6 < this.zombieWithoutModel.size(); int6++) {
            IsoZombie isoZombie2 = (IsoZombie)this.zombieWithoutModel.get(int6);
            if (isoZombie2.hasActiveModel()) {
                isoZombie2.setSceneCulled(true);
            }

            if (isoZombie2.hasAnimationPlayer()) {
                isoZombie2.getAnimationPlayer().bDoBlending = false;
            }
        }
    }

    public void render() {
        IsoWorld.s_performance.isoWorldRender.invokeAndMeasure(this, IsoWorld::renderInternal);
    }

    private void renderInternal() {
        if (this.bDrawWorld) {
            if (IsoCamera.CamCharacter != null) {
                SpriteRenderer.instance.doCoreIntParam(0, IsoCamera.CamCharacter.x);
                SpriteRenderer.instance.doCoreIntParam(1, IsoCamera.CamCharacter.y);
                SpriteRenderer.instance.doCoreIntParam(2, IsoCamera.CamCharacter.z);

                try {
                    this.sceneCullZombies();
                } catch (Throwable throwable0) {
                    ExceptionLogger.logException(throwable0);
                }

                try {
                    WeatherFxMask.initMask();
                    DeadBodyAtlas.instance.render();
                    WorldItemAtlas.instance.render();
                    this.CurrentCell.render();
                    this.DrawIsoCursorHelper();
                    DeadBodyAtlas.instance.renderDebug();
                    PolygonalMap2.instance.render();
                    zombie.WorldSoundManager.instance.render();
                    WorldFlares.debugRender();
                    WorldMarkers.instance.debugRender();
                    ObjectAmbientEmitters.getInstance().render();
                    ZombieVocalsManager.instance.render();
                    LineDrawer.render();
                    WeatherFxMask.renderFxMask(IsoCamera.frameState.playerIndex);
                    if (GameClient.bClient) {
                        ClientServerMap.render(IsoCamera.frameState.playerIndex);
                        PassengerMap.render(IsoCamera.frameState.playerIndex);
                    }

                    SkyBox.getInstance().render();
                } catch (Throwable throwable1) {
                    ExceptionLogger.logException(throwable1);
                }
            }
        }
    }

    private void DrawIsoCursorHelper() {
        if (Core.getInstance().getOffscreenBuffer() == null) {
            IsoPlayer isoPlayer = IsoPlayer.getInstance();
            if (isoPlayer != null && !isoPlayer.isDead() && isoPlayer.isAiming() && isoPlayer.PlayerIndex == 0 && isoPlayer.JoypadBind == -1) {
                if (!zombie.GameTime.isGamePaused()) {
                    float _float = 0.05F;
                    switch (Core.getInstance().getIsoCursorVisibility()) {
                        case 0:
                            return;
                        case 1:
                            _float = 0.05F;
                            break;
                        case 2:
                            _float = 0.1F;
                            break;
                        case 3:
                            _float = 0.15F;
                            break;
                        case 4:
                            _float = 0.3F;
                            break;
                        case 5:
                            _float = 0.5F;
                            break;
                        case 6:
                            _float = 0.75F;
                    }

                    if (Core.getInstance().isFlashIsoCursor()) {
                        if (this.flashIsoCursorInc) {
                            this.flashIsoCursorA += 0.1F;
                            if (this.flashIsoCursorA >= 1.0F) {
                                this.flashIsoCursorInc = false;
                            }
                        } else {
                            this.flashIsoCursorA -= 0.1F;
                            if (this.flashIsoCursorA <= 0.0F) {
                                this.flashIsoCursorInc = true;
                            }
                        }

                        _float = this.flashIsoCursorA;
                    }

                    Texture texture = Texture.getSharedTexture("media/ui/isocursor.png");
                    int int0 = (int)((float)(texture.getWidth() * Core.TileScale) / 2.0F);
                    int int1 = (int)((float)(texture.getHeight() * Core.TileScale) / 2.0F);
                    SpriteRenderer.instance.setDoAdditive(true);
                    SpriteRenderer.instance
                        .renderi(texture, Mouse.getX() - int0 / 2, Mouse.getY() - int1 / 2, int0, int1, _float, _float, _float, _float, null);
                    SpriteRenderer.instance.setDoAdditive(false);
                }
            }
        }
    }

    public void update() {
        IsoWorld.s_performance.isoWorldUpdate.invokeAndMeasure(this, IsoWorld::updateInternal);
    }

    private void updateInternal() {
        this.m_frameNo++;

        try {
            if (GameServer.bServer) {
                VehicleManager.instance.serverUpdate();
            }
        } catch (Exception exception0) {
            exception0.printStackTrace();
        }

        WorldSimulation.instance.update();
        ImprovedFog.update();
        this.helicopter.update();
        long _long = System.currentTimeMillis();
        if (_long - this.emitterUpdateMS >= 30L) {
            this.emitterUpdateMS = _long;
            this.emitterUpdate = true;
        } else {
            this.emitterUpdate = false;
        }

        for (int int0 = 0; int0 < this.currentEmitters.size(); int0++) {
            BaseSoundEmitter baseSoundEmitter = (BaseSoundEmitter)this.currentEmitters.get(int0);
            if (this.emitterUpdate || baseSoundEmitter.hasSoundsToStart()) {
                baseSoundEmitter.tick();
            }

            if (baseSoundEmitter.isEmpty()) {
                FMODSoundEmitter fMODSoundEmitter = Type.tryCastTo(baseSoundEmitter, FMODSoundEmitter.class);
                if (fMODSoundEmitter != null) {
                    fMODSoundEmitter.clearParameters();
                }

                this.currentEmitters.remove(int0);
                this.freeEmitters.push(baseSoundEmitter);
                IsoObject isoObject = (IsoObject)this.emitterOwners.remove(baseSoundEmitter);
                if (isoObject != null && isoObject.emitter == baseSoundEmitter) {
                    isoObject.emitter = null;
                }

                int0--;
            }
        }

        if (!GameClient.bClient && !GameServer.bServer) {
            IsoMetaCell isoMetaCell = this.MetaGrid.getCurrentCellData();
            if (isoMetaCell != null) {
                isoMetaCell.checkTriggers();
            }
        }

        zombie.WorldSoundManager.instance.initFrame();
        ZombieGroupManager.instance.preupdate();
        OnceEvery.update();
        zombie.CollisionManager.instance.initUpdate();

        for (int int1 = 0; int1 < this.CurrentCell.getBuildingList().size(); int1++) {
            ((IsoBuilding)this.CurrentCell.getBuildingList().get(int1)).update();
        }

        ClimateManager.getInstance().update();
        ObjectRenderEffects.updateStatic();
        this.CurrentCell.update();
        IsoRegions.update();
        HaloTextHelper.update();
        zombie.CollisionManager.instance.ResolveContacts();

        for (int int2 = 0; int2 < this.AddCoopPlayers.size(); int2++) {
            AddCoopPlayer addCoopPlayer = (AddCoopPlayer)this.AddCoopPlayers.get(int2);
            addCoopPlayer.update();
            if (addCoopPlayer.isFinished()) {
                this.AddCoopPlayers.remove(int2--);
            }
        }

        if (!GameServer.bServer) {
            IsoPlayer.UpdateRemovedEmitters();
        }

        try {
            if (PlayerDB.isAvailable()) {
                PlayerDB.getInstance().updateMain();
            }

            if (ClientPlayerDB.isAvailable()) {
                ClientPlayerDB.getInstance().updateMain();
            }

            VehiclesDB2.instance.updateMain();
        } catch (Exception exception1) {
            ExceptionLogger.logException(exception1);
        }

        if (this.updateSafehousePlayers > 0 && (GameServer.bServer || GameClient.bClient)) {
            this.updateSafehousePlayers--;
            if (this.updateSafehousePlayers == 0) {
                this.updateSafehousePlayers = 200;
                SafeHouse.updateSafehousePlayersConnected();
            }
        }

        m_animationRecorderDiscard = false;
    }

    public IsoCell getCell() {
        return this.CurrentCell;
    }

    private void PopulateCellWithSurvivors() {
    }

    public int getWorldSquareY() {
        return this.CurrentCell.ChunkMap[IsoPlayer.getPlayerIndex()].WorldY * 10;
    }

    public int getWorldSquareX() {
        return this.CurrentCell.ChunkMap[IsoPlayer.getPlayerIndex()].WorldX * 10;
    }

    public IsoMetaChunk getMetaChunk(int wx, int wy) {
        return this.MetaGrid.getChunkData(wx, wy);
    }

    public IsoMetaChunk getMetaChunkFromTile(int wx, int wy) {
        return this.MetaGrid.getChunkDataFromTile(wx, wy);
    }

    public float getGlobalTemperature() {
        return ClimateManager.getInstance().getTemperature();
    }

    @Deprecated
    public void setGlobalTemperature(float globalTemperature) {
    }

    public String getWeather() {
        return this.weather;
    }

    public void setWeather(String _weather) {
        this.weather = _weather;
    }

    public int getLuaSpawnCellX() {
        return this.luaSpawnCellX;
    }

    public void setLuaSpawnCellX(int _luaSpawnCellX) {
        this.luaSpawnCellX = _luaSpawnCellX;
    }

    public int getLuaSpawnCellY() {
        return this.luaSpawnCellY;
    }

    public void setLuaSpawnCellY(int _luaSpawnCellY) {
        this.luaSpawnCellY = _luaSpawnCellY;
    }

    public int getLuaPosX() {
        return this.luaPosX;
    }

    public void setLuaPosX(int _luaPosX) {
        this.luaPosX = _luaPosX;
    }

    public int getLuaPosY() {
        return this.luaPosY;
    }

    public void setLuaPosY(int _luaPosY) {
        this.luaPosY = _luaPosY;
    }

    public int getLuaPosZ() {
        return this.luaPosZ;
    }

    public void setLuaPosZ(int _luaPosZ) {
        this.luaPosZ = _luaPosZ;
    }

    public String getWorld() {
        return Core.GameSaveWorld;
    }

    public void transmitWeather() {
        if (GameServer.bServer) {
            GameServer.sendWeather();
        }
    }

    public boolean isValidSquare(int _x, int _y, int z) {
        return z >= 0 && z < 8 ? this.MetaGrid.isValidSquare(_x, _y) : false;
    }

    public ArrayList<RandomizedZoneStoryBase> getRandomizedZoneList() {
        return this.randomizedZoneList;
    }

    public ArrayList<RandomizedBuildingBase> getRandomizedBuildingList() {
        return this.randomizedBuildingList;
    }

    public ArrayList<RandomizedVehicleStoryBase> getRandomizedVehicleStoryList() {
        return this.randomizedVehicleStoryList;
    }

    public RandomizedVehicleStoryBase getRandomizedVehicleStoryByName(String name) {
        for (int _int = 0; _int < this.randomizedVehicleStoryList.size(); _int++) {
            RandomizedVehicleStoryBase randomizedVehicleStoryBase = (RandomizedVehicleStoryBase)this.randomizedVehicleStoryList.get(_int);
            if (randomizedVehicleStoryBase.getName().equalsIgnoreCase(name)) {
                return randomizedVehicleStoryBase;
            }
        }

        return null;
    }

    public RandomizedBuildingBase getRBBasic() {
        return this.RBBasic;
    }

    public String getDifficulty() {
        return Core.getDifficulty();
    }

    public void setDifficulty(String difficulty) {
        Core.setDifficulty(difficulty);
    }

    public static boolean getZombiesDisabled() {
        return NoZombies || !zombie.SystemDisabler.doZombieCreation || zombie.SandboxOptions.instance.Zombies.getValue() == 6;
    }

    public static boolean getZombiesEnabled() {
        return !getZombiesDisabled();
    }

    public ClimateManager getClimateManager() {
        return ClimateManager.getInstance();
    }

    public IsoPuddles getPuddlesManager() {
        return IsoPuddles.getInstance();
    }

    public static int getWorldVersion() {
        return 195;
    }

    public HashMap<String, ArrayList<Double>> getSpawnedZombieZone() {
        return this.spawnedZombieZone;
    }

    public int getTimeSinceLastSurvivorInHorde() {
        return this.timeSinceLastSurvivorInHorde;
    }

    public void setTimeSinceLastSurvivorInHorde(int _timeSinceLastSurvivorInHorde) {
        this.timeSinceLastSurvivorInHorde = _timeSinceLastSurvivorInHorde;
    }

    public float getWorldAgeDays() {
        float _float = (float)zombie.GameTime.getInstance().getWorldAgeHours() / 24.0F;
        return _float + (float)((zombie.SandboxOptions.instance.TimeSinceApo.getValue() - 1) * 30);
    }

    public HashMap<String, ArrayList<String>> getAllTiles() {
        return this.allTiles;
    }

    public ArrayList<String> getAllTilesName() {
        ArrayList arrayList = new ArrayList();
        Iterator iterator = this.allTiles.keySet().iterator();

        while (iterator.hasNext()) {
            arrayList.add((String)iterator.next());
        }

        Collections.sort(arrayList);
        return arrayList;
    }

    public ArrayList<String> getAllTiles(String filename) {
        return (ArrayList<String>)this.allTiles.get(filename);
    }

    public boolean isHydroPowerOn() {
        return this.bHydroPowerOn;
    }

    public void setHydroPowerOn(boolean on) {
        this.bHydroPowerOn = on;
    }

    public ArrayList<String> getTileImageNames() {
        return this.tileImages;
    }

    private static class CompDistToPlayer implements Comparator<IsoZombie> {
        public float px;
        public float py;

        public int compare(IsoZombie isoZombie0, IsoZombie isoZombie1) {
            float float0 = IsoUtils.DistanceManhatten((float)((int)isoZombie0.x), (float)((int)isoZombie0.y), this.px, this.py);
            float float1 = IsoUtils.DistanceManhatten((float)((int)isoZombie1.x), (float)((int)isoZombie1.y), this.px, this.py);
            if (float0 < float1) {
                return -1;
            } else {
                return float0 > float1 ? 1 : 0;
            }
        }
    }

    private static class CompScoreToPlayer implements Comparator<IsoZombie> {
        public int compare(IsoZombie isoZombie0, IsoZombie isoZombie1) {
            float float0 = this.getScore(isoZombie0);
            float float1 = this.getScore(isoZombie1);
            if (float0 < float1) {
                return 1;
            } else {
                return float0 > float1 ? -1 : 0;
            }
        }

        public float getScore(IsoZombie isoZombie) {
            float float0 = Float.MIN_VALUE;

            for (int _int = 0; _int < 4; _int++) {
                IsoPlayer isoPlayer = IsoPlayer.players[_int];
                if (isoPlayer != null && isoPlayer.current != null) {
                    float float1 = isoPlayer.getZombieRelevenceScore(isoZombie);
                    float0 = Math.max(float0, float1);
                }
            }

            return float0;
        }
    }

    public class Frame {
        public ArrayList<Integer> xPos = new ArrayList();
        public ArrayList<Integer> yPos = new ArrayList();
        public ArrayList<Integer> Type = new ArrayList();

        public Frame() {
            Iterator iterator = IsoWorld.instance.CurrentCell.getObjectList().iterator();

            while (iterator != null && iterator.hasNext()) {
                IsoMovingObject isoMovingObject = (IsoMovingObject)iterator.next();
                byte _byte = 2;
                if (isoMovingObject instanceof IsoPlayer) {
                    _byte = 0;
                } else if (isoMovingObject instanceof IsoSurvivor) {
                    _byte = 1;
                } else {
                    if (!(isoMovingObject instanceof IsoZombie) || ((IsoZombie)isoMovingObject).Ghost) {
                        continue;
                    }

                    _byte = 2;
                }

                this.xPos.add((int)isoMovingObject.getX());
                this.yPos.add((int)isoMovingObject.getY());
                this.Type.add(Integer.valueOf(_byte));
            }
        }
    }

    public static class MetaCell {
        public int x;
        public int y;
        public int zombieCount;
        public IsoDirections zombieMigrateDirection;
        public int[][] from = new int[3][3];
    }

    private static class s_performance {
        static final PerformanceProfileProbe isoWorldUpdate = new PerformanceProfileProbe("IsoWorld.update");
        static final PerformanceProfileProbe isoWorldRender = new PerformanceProfileProbe("IsoWorld.render");
    }
}
